UITextView禁用文本选择 [英] UITextView disabling text selection

查看:117
本文介绍了UITextView禁用文本选择的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我很难让UITextView禁止选择文本.

I'm having a hard time getting the UITextView to disable the selecting of the text.

我尝试过:

canCancelContentTouches = YES;

我尝试了子类化和覆盖:

I've tried subclassing and overwriting:

- (BOOL)canPerformAction:(SEL)action withSender:(id)sender   

(但只有在选择后才被调用)

(But that gets called only After the selection)

- (BOOL)touchesShouldCancelInContentView:(UIView *)view;  

(我完全看不到被解雇)

(I don't see that getting fired at all)

- (BOOL)touchesShouldBegin:(NSSet *)touches
                 withEvent:(UIEvent *)event
             inContentView:(UIView *)view; 

(我也看不到被解雇)

我想念什么?

推荐答案

问题如何在UITextView中禁用复制,剪切,选择和全选对此可行的解决方案:

Issue How disable Copy, Cut, Select, Select All in UITextView has a workable solution to this that I've just implemented and verified:

子类并覆盖canBecomeFirstResponder:

- (BOOL)canBecomeFirstResponder {
    return NO;
}

请注意,这会禁用链接和其他可点击的文本内容.

Note that this disables links and other tappable text content.

这篇关于UITextView禁用文本选择的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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