I am doing a login page, whereby if the user press the login button without filling up the username/password, an alertview will pop up. How do I focus on the textfield and bring up the keyb开发者_Python百科oard accordingly after the user dismiss the alertview?
What is the method to call to set focus on a particular UITextField? Thanks!
Make sure your UIAlertView's delegate is your view controller (self), and in the implementation of the UIAlertView delegate method alertView:clickedButtonAtIndex:
, call [usernameTextField becomeFirstResponder]
. Easy! (Make sure your view controller class adopts the UIAlertViewDelegate
protocol.)
[myTextField becomeFirstResponder];
You should use a code [mytextField becomeFirstResponder];
in your – alertView:clickedButtonAtIndex:
delegate method.
精彩评论