UITextField focus

微笑、不失礼 提交于 2019-11-27 10:40:21

问题


How can I programmatically assign focus to a specific UITextField in a view? I have several fields and on view display, I'd like to put the cursor on a specific field, not the first one at top.


回答1:


Try doing this in viewWillAppear:

[desiredField becomeFirstResponder];

By making the field the first responder, it have focus and the keyboard will be displayed.




回答2:


Set the first responder for your view to be the text field. This can be done in IB.



来源:https://stackoverflow.com/questions/1014999/uitextfield-focus

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!