I have a bunch of text fields in a registration form that are organized in two vertical stack views in a XIB file. I noticed that when running the app in the simulator I can press the Tab key and iOS will automatically move on to the next text field.
But this doesn't work sometimes, and I was wondering why. Sometimes the system focuses a text field from another stack view instead of the field below it.
I have already set up a chain of Next text fields (when pressing Next on the software keyboard) like this:
- (BOOL)textFieldShouldReturn:(UITextField *)textField {
NSUInteger index = [self.textFields indexOfObject:textField];
if (index != NSNotFound) {
if (index == self.textFields.count - 1) {
[textField resignFirstResponder];
[self createAccount];
} else {
UITextField *nextTextField = self.textFields[index + 1];
[nextTextField becomeFirstResponder];
}
return NO;
}
return YES;
}
textFields
is an array of all text fields that this screen has from top to bottom.
I just want to be able to fill the form fast by typing a few characters and pressing Tab without additional mouse clicks. Is it possible?
It seems that -textFieldShouldReturn
is not called during this "tab switch" so I can't control which text field becomes the next first responder. What is the trick for getting them to focus in the right order?