Reputation: 49
How to I go from one textfield to the next with the next button?
Here is my code that will not work:
- (BOOL)textFieldShouldReturn:(UITextField *)theTextField {
if (theTextField == self.amountField) {
[theTextField resignFirstResponder];
} else if (theTextField == self.businessField) {
[self.memoField becomeFirstResponder];
}
return YES;
}
Upvotes: 1
Views: 237
Reputation: 5760
there are many solutions but I prefer this one:
[self.firstTextField addTarget:self.secondTextField action:@selector(becomeFirstResponder) forControlEvents:UIControlEventEditingDidEndOnExit];
[self.secondTextField addTarget:self.thirdTextField action:@selector(becomeFirstResponder) forControlEvents:UIControlEventEditingDidEndOnExit];
just set it up in viewDidLoad
Upvotes: 0
Reputation: 332
Call [textField resignFirstResponder];
before your first conditional
Upvotes: 1