Search code examples
buttonios6sdkkeyboarduitextfield

"Next" key doesn't work


I have two TextFiels. On first I set "Next" button on keybord, but the button "Done" are working on the second field. I wrote this code.

- (BOOL)textFieldShouldReturn:(UITextField *)theTextField {
if (theTextField == self.loginField) {
    [theTextField resignFirstResponder];
} else if (theTextField == self.passField) {
    [self.passField becomeFirstResponder];
}
return YES;
}

Maybe I was wrong in something.


Solution

  •     -(BOOL)textFieldShouldReturn:(UITextField *)textField
        {
            if(textField == self.loginField)
            {
                [self.passField becomeFirstResponder];
            }
            else if(textField == self.passField)
            {
                [textField resignFirstResponder];
            }
            return YES;
        }
    
    In xib, select LoginField - Return key set as "Next", Select PassField - Return key as "Done"/"Next".