如何在UITextField上自动打开键盘? [英] How to open the keyboard automatically on UITextField?
问题描述
我有一个非常简单的表格,当它打开一个单元格时,它会打开一个带有一个UITextfield的新视图。我想要的是键盘将自动打开,用户不必触摸UITextfield。
I have a very simple table and when tocuh a cell it opens a new view with one UITextfield. All I want is that the keyboard will automatically opens, without the user have to touch the UITextfield.
这一切都在Interface Builder中完成,所以我不知道我是怎么做的这个。我想我需要在某个时候设置焦点?
Its all done in Interface Builder, so I am not sure how I do this. I guess I need to set the focus at some point ?
谢谢
推荐答案
要使键盘立即显示,您需要使用以下行将文本字段设置为第一响应者:
To cause the keyboard to show up immediately you'll need to set the text field as the first responder using the following line:
[textField becomeFirstResponder];
您可能希望将其放在 viewDidAppear中:
方法。
You may want to place this in the viewDidAppear:
method.
这篇关于如何在UITextField上自动打开键盘?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!