You can use the TextField delegation method as shown below: -
- (BOOL)textFieldShouldReturn:(UITextField *)textField { if(self.passwordTextField isFirstResponder){ [self.passwordTextField resignFirstResponder]; //Resign the keyboard. [self loginMethod]; //call your login method here. } //Below case when user tap return key when done with login info then we move focus from login textfield to password textfield so as not making user to do this and for ease of user. else{ [self.loginTextField resignFirstResponder]; [self.passwordTextField becomeFirstResponder]; } return YES; }
Also, be sure to set the delegate as shown below and set the UITextFieldDelegate to yourClass.h
self.passwordTextField.delegate = self; self.loginTextField.delegate = self;
source share