如何在UITextView中默认显示键盘? [英] How do I show the keyboard by default in UITextView?

查看:158
本文介绍了如何在UITextView中默认显示键盘?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想创建一个仅由UITextView组成的视图。当视图第一次显示时,默认情况下,我想键盘是可见的,准备好文本输入。这样,用户不必先触摸UITextView即可开始编辑。

I want to create a view that consists solely of a UITextView. When the view is first shown, by default, I'd like the keyboard to be visible and ready for text entry. This way, the user does not have to touch the UITextView first in order to begin editing.

这是否可能?我看到类有一个通知调用UITextViewTextDidBeginEditingNotification但我不知道如何发送,或者如果这是甚至正确的方法。

Is this possible? I see the class has a notification called UITextViewTextDidBeginEditingNotification but I'm not sure how to send that, or if that is even the right approach.

推荐答案

完成只需发送becomeFirstResponder消息到您的UITextField,如下(假设你有一个名为textField的outlet,该字段):

to accomplish that just send the becomeFirstResponder message to your UITextField, as follows (assuming you have an outlet called textField, pointing to the field in question):

- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    [textField becomeFirstResponder];
}

这篇关于如何在UITextView中默认显示键盘?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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