开发者

focus on UITextField

开发者 https://www.devze.com 2023-03-09 05:39 出处:网络
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开发者_Pyth

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号