I have two text fields for username and password and submit button. When the submit button is pressed, a check is performed to determine if a username and password have been entered. If not, a warning message appears, and a field whose value has not been entered becomes the first responder.
-(IBAction)loginPressed:(id)sender { if ([username.text length] == 0) { [self showAlert:@"Invalid Username/ Password"]; [username becomeFirstResponder]; return; } if ([password.text length] == 0) { [self showAlert:@"Invalid Username/ Password"]; [password becomeFirstResponder]; return; } }
I noticed that when the button is pressed, the button remains selected for about 1.5 seconds, and then a warning is displayed. If I comment on the becomeFirstResponder method, it works without a pause. However, I need to becomeFirstResponder be there. How can I speed up the work?
source share