如何防止键盘在TextView上显示(不解除)? [英] How to prevent the keyboard from showing (not dismissing) on a TextView?

查看:114
本文介绍了如何防止键盘在TextView上显示(不解除)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道在TextView中如何禁用(而不是如何解雇)iOS键盘。当用户触摸TextView时,我甚至不希望键盘出现。



我发现的所有例子都是让键盘在出现后消失。 / p>

我最接近的是设置textView.userInteractionEnabled = NO;但是也摆脱了滚动(我想保持滚动)。



提前谢谢!!

解决方案

尝试在文本视图的委托中实现以下方法:

   - (BOOL)textViewShouldBeginEditing:(UITextView *)textView {
return NO;
}


I would like to know how to DISABLE (not how to dismiss) the iOS keyboard in a TextView. I don`t even want the keyboard to show up when the user touches the TextView.

All of the examples I found were to make the keyboard disappear AFTER it appears.

The closest thing I got was to set textView.userInteractionEnabled = NO; but that gets rid of the scrolling as well (I want to keep the scrolling).

Thank you in advance!!

解决方案

Try to implement the following method in text view's delegate:

- (BOOL)textViewShouldBeginEditing:(UITextView *)textView{
    return NO;
}

这篇关于如何防止键盘在TextView上显示(不解除)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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