0
votes

I have a login view controller with 2 text fields for username and password entry.

Once the user is done entering their password in the password text field, they press the "Done" return key on the keyboard and my IBAction is performed and tries to log them in.

However, if the login is unsuccessful I show them a UIAlertView warning that tells them it failed and then they press "OK" to dismiss the alert view.

I would like to make is to that when they press "OK" to dismiss the UIAlertView, the password text field's keyboard will pop up again / reappear so they can try entering in their password again.

Is there a way to programmatically call a certain text field's keyboard to popup?

Thanks.

EDIT: The keyboard is now successfully popping up using this code:

[_passwordEntry becomeFirstResponder];

but I would like to make it so that it only pops up when the user taps the "OK" button on the UIAlertView.

Is there a way to "listen" for the UIAlertView's "cancelButtonTitle" or dismissal and call my keyboard method when that happens?

1

1 Answers

1
votes

Just got it working with the following code:

-(void) alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{

    //u need to change 0 to other value(,1,2,3) if u have more buttons.then u can check which button was pressed.

    if (buttonIndex == 0) {

        [_passwordEntry becomeFirstResponder];


    }    

}

Taken from this SO Answer: https://stackoverflow.com/a/6875248/3344977