Possible Duplicate:
How to navigate through textfields (Next / Done Buttons)
iOS app “next” key won’t go to the next text field
I have two text fields in my view and I'd like the cursor to move from the email text field to the password text field when the user hits the return key. If the password text field is the one in focus, I'd like the keyboard to hide. Here's what I currently have, but it doesn't work...
- (BOOL)textFieldShouldReturn:(UITextField *)textField {
return YES;
}
- (void)textFieldDidEndEditing:(UITextField *)textField {
if(textField == self.emailTextField) {
[self.passwordTextField becomeFirstResponder];
}
else if (textField == self.passwordTextField) {
[textField resignFirstResponder];
}
}
What am I missing? Thanks so much in advance for your wisdom!
The code you have in the textFieldDidEndEditing:
method belongs in the textFieldShouldReturn:
method.
- (BOOL)textFieldShouldReturn:(UITextField *)textField {
if(textField == self.emailTextField) {
[self.passwordTextField becomeFirstResponder];
} else if (textField == self.passwordTextField) {
[textField resignFirstResponder];
}
return NO;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With