iosuitableviewuitextfieldfirst-responder

Changing focus between UITextFields in cells at same UITableView


In my iPad application i have few UITableView on same view created programmatically. They must pretend one multicolumn table. Each cell contains UITextField. It's size is equal to cell's size (its the reason why i cant get UITableView's delegate methods didSelect/didDeselect row). My problem is when i begin edit one text field then try to remove focus to other textfield it needs two taps. After first tap no one of cell is not editing. Such behavior observing only inside same table. If i want to change focus to other table its possible in one tap. What i missed?

Here is my UITextField Delegate methods in Cell's class

- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField
{
    if ([_delegate checkForAccess:self]) {
        if (!((CTKTextField *)textField).isEditable)
        {
            [_delegate callPickerUnderCell:self];
            return NO;
        }
        else
        {
            [_delegate getPosition:self];
            return YES;
        }
    }
    else return NO;
}

-(BOOL) textFieldShouldReturn:(UITextField *)textField
{
    [textField resignFirstResponder];
    return YES;
}
- (BOOL)textFieldShouldEndEditing:(UITextField *)textField
{
    if (_textField.text.length == -1)
    {
        _textField.rightView = nil;
    }
    return YES;
}

- (void)textFieldDidEndEditing:(UITextField *)textField
{
    NSString *input = textField.text;

    [_delegate saveEdit:self withText:input];
}

Solution

  • If textFieldShouldBeginEditing is called after first tap and you return YES then text field starts editing. Probably you are making endEditing to the whole tableView after that.

    If you call endEditing on the specific cell in your cell's delegate instead of the whole table view it should work.