I have two textfields as emailTextField and passwordTextField.
I have written the following textfield delegate methods for moving one text field to another:
- (BOOL)textFieldShouldReturn:(UITextField *)textField
{
if (textField == emailTextField) {
[textField resignFirstResponder];
[passwordTextField becomeFirstResponder];
} else if (textField == passwordTextField) {
[textField resignFirstResponder];
}
return YES;
}
When I click to next button after entering email then it will go to password textfield but within a fraction of a second, the keyboard will disappear.
What is the solution for this? Is there a mistake in the code?
Try this
- (BOOL)textFieldShouldReturn:(UITextField *)textField
{
if (textField == emailTextField) {
[passwordTextField becomeFirstResponder];
} else if (textField == passwordTextField) {
[textField resignFirstResponder];
}
return YES;
}