以编程方式将UITextField设置为编辑模式 [英] Setting a UITextField into editing mode programmatically

查看:79
本文介绍了以编程方式将UITextField设置为编辑模式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 UITextField ,我想以编程方式设置为编辑模式(屏幕上的键盘和文本字段框中的光标)。我知道当此视图出现在屏幕上时,用户将处于编辑模式,因此我希望用户不必点击文本字段。

I have a UITextField that I want to set into editing mode (keyboard on screen and cursor in text field box) programatically. I know that the user will be in editing mode when this view appears onscreen, so I want to save the user from having to tap the text field.

UITextField 的编辑属性是只读的 - 因此不起作用。有没有办法将 UITextField 设置为编辑模式,屏幕上有键盘,以编程方式?

The "editing" property of a UITextField is read only - so that doesn't work. Is there a way to set the UITextField into editing mode, with a keyboard onscreen, programmatically?

推荐答案

在UITextField上调用 becomeFirstResponder

Call becomeFirstResponder on the UITextField.

相关问题:
如何在UITextView中默认显示键盘?

这篇关于以编程方式将UITextField设置为编辑模式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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