Hi,
I have a table with 3 UITextFields added to the content views of cells (1 row per section). I have a 4th section that I insert so that I can scroll the particular field to be above the keyboard.
The problem I have (on the iPad only) is that when one of the text fields has firstResponder, it does not relinquish it when user taps on another field. Are there differences in the responder chain on an ipad? In the bellow code for my view controllers UITextFieldDelegate - textFieldShouldEndEditing does not get called when touching another field. Pressing the done button works as expected (unless another field has been touched).
Anything wrong with the code bellow?
- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField {
if (!_editing++) {
[self.tableView insertSections:[NSIndexSet indexSetWithIndex:4] withRowAnimation:UITableViewRowAnimationNone];
}
// scroll to section number in the text fields tag
[self.tableView scrollToRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:textField.tag] atScrollPosition:UITableViewScrollPositionTop animated:YES];
return YES;
}
- (void) textFieldDidBeginEditing:(UITextField *)textField {
self.navigationItem.rightBarButtonItem = [[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:textField action:@selector(resignFirstResponder)] autorelease];
}
- (BOOL)textFieldShouldEndEditing:(UITextField *)textField {
if (_editing-- == 1) {
//
[self.tableView deleteSections:[NSIndexSet indexSetWithIndex:4] withRowAnimation:UITableViewRowAnimationNone];
}
self.navigationItem.rightBarButtonItem = nil;
// do something with the text here...
return YES;
}