如何在UITextField上自动打开键盘? [英] How to open the keyboard automatically on UITextField?

查看:144
本文介绍了如何在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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆