After a UITextField
is edited and return is pressed, I loop through and check for the next field. I get the index path of that field, then save it. Next I reload table data and when the table is being built, if the indexPath
is equal to the indexPath
of what would be the next text field, then I set it as first responder.
I grab the correct textField
at the correct indexPath
and everything, however first responder doesn't get set. Instead, focus just disappears.
My code:
//inside UITextFieldShouldReturn
for (int i = uiTextField.fieldTag + 1; i < group.fields.count; i++) {
ObjectEditField *field = [group.fields objectAtIndex:i];
if (field.propName && field.updateObjectOnEdit == YES && [field isKindOfClass:[ObjectEditTextField class]]) {
// set the active field
activeField = field;
// obtain a pointer to the textfield object and set it to be the first responder
ObjectEditTextField *textField = (ObjectEditTextField *)field;
if (![textField.field isFirstResponder]) {
UITableViewCell *cell = (UITableViewCell *)[[[uiTextField superview] superview] superview];
firstResponderIndexPath = [_fieldsTableView indexPathForCell:cell];
Then once I have the firstResponderIndexPath
I call reloadData
on the table view, and inside tableView:cellForRowAtIndexPath:
I have:
if (firstResponderIndexPath.row + 1 == indexPath.row)
{
ObjectEditTextField *textField = (ObjectEditTextField *)field;
NSLog(@"display: %@", textField.field.text);
[textField.field becomeFirstResponder];
}
The output for the NSLog
is correct and the field it should be. However the first responder doesn't get set correctly.