On the keyboard either iphone or ipad, when the user press the Next(Return) button
I have made the Return button, the Next button to be able to go to the next l开发者_JAVA百科ine (textfield). How can I capture that the Next button was pressed(first question)? Then set focus on the next textfield (second question)?
Thank you.
Use the:
becomeFirstResponder
method in the
- textField:DidEndEditing
Of your UITextField delegate to set the next text field as the "first responder". This will focus the input on whoever is the first responder.
Also set:
myTextField.delegate = self;
Then use this to capture when a user clicks Return:
// this helps dismiss the keyboard then the "done" button is clicked
- (BOOL)textFieldShouldReturn:(UITextField *)textField
{
[textField resignFirstResponder];
// Or [textField2 becomeFirstResponder]; to focus the next field
return NO; // return NO so that a newline doesnt get put in the next input (usually only happens if the next field is a textView not a textField
}
Check out this tutorial too to see it in action with a keyboard toolbar.
精彩评论