Question

Here is the UI: I have a table view that has rows including text fields. For example row1 has textField1 and row2 has textField2.

Now, if the user taps the textField1, everything works fine. The delegate is called and everything.

If the user, then, taps the textField2, only the textFieldDidEndEditing: is called for textField1. textFieldDidBeginEditing: is not called for textField2 (I am pretty sure that textField2 delegate is set, because when I then tap textField2 (again), it starts editing (textFieldDidBeginEditing: is now called)

You may think this is not a real problem. The problem is that the iOS keeps showing the keyboard! With no text fields associated to it! I even loop to all text fields in all visible rows and resign them with no luck.

Seems a bug in iOS, right?

Edit: Here is the code in the delegate

   - (void) textFieldDidBeginEditing:(UITextField *)textField {

    [self fixTableViewOffsets];

    RSMCellEditPricesCell *cell = (RSMCellEditPricesCell *) [[textField superview] superview];
    [self.tableView scrollToRowAtIndexPath:[self.tableView indexPathForCell:cell]
                          atScrollPosition:UITableViewScrollPositionTop
                                  animated:YES];

}

- (void) textFieldDidEndEditing:(UITextField *)textField {

    self.currentPriceTextField = nil;
    [self fixTableViewOffsets];
    [self.tableView reloadData];

}
Was it helpful?

Solution 2

I couldn't find a fix for it. However, as a workaround, I disabled the second text field. When the user taps this field, it will trigger the touch event on cell, not the text field which will dismiss the keyboard. Then, I enable all text fields and the user can select this second text field again.

It's not quite a solution and it doesn't provide the best UX. Still, it work.

OTHER TIPS

First of all, be careful with the naming conventions, if you are adding a label at the end of a variable that variable should be a UILabel not a UITextField. Second your problem might be in the textFieldDidEndEditing method, you are calling resignFirstResponder on all your text fields(if the cell.priceLabel is a text field). You shouldn't callresignFirstResponder in textFieldDidEndEditing or textFieldSouldReturn because if those methods are called the text fields are already resign as first responder.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top