I have two text fields in a UIAlertView. I want the second one to become the first responder so that the user doesn't have to tap on it. After I show the alert view, I have this code:
[textField becomeFirstResponder];
The only problem is that it does not work. The first text field has the typer in it. Any ideas? Thanks for your help.
I had this same problem with trying to set focus to the password field in the UIAlertView (I was pre-populating the username). I had to use the delegate method:
- (void)didPresentAlertView:(UIAlertView *)alertView {
UITextField *textField = [alertView textFieldAtIndex:0];
[textField becomeFirstResponder];
}
If I tried it on willPresentAlertView or when I create the alertView, it didn't work, only on didPresentAlertView. I hope this helps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With