I have two textfields for username and password and a submit button. When the submit button is pressed a check is performed to see if the username and password was typed or not. If not it shows an alert message and the field whose value was not 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 observed that on clicking the button, the button remains selected for about 1.5 seconds and then the alert is shown. If I comment out the becomeFirstResponder
method, it works without any pause. However I need becomeFirstResponder
to be there. How do I speed things up using this?