如何在UITextView中禁用复制,剪切,选择,全选 [英] How disable Copy, Cut, Select, Select All in UITextView
本文介绍了如何在UITextView中禁用复制,剪切,选择,全选的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当我按下屏幕时,默认显示 UITextView
的复制,剪切,选择,全选功能。但是,在我的项目中, UITextField
只是只读。我不需要这个功能。请告诉我如何禁用此功能。
The UITextView
's Copy, Cut, Select, Select All functionality is shown by default when I press down on the screen. But, in my project the UITextField
is only read only. I do not require this functionality. Please tell me how to disable this feature.
推荐答案
禁用粘贴板操作的最简单方法是创建<$ c的子类$ c> UITextView 覆盖 canPerformAction:withSender:
方法返回 NO
进行操作你不想允许:
The easiest way to disable pasteboard operations is to create a subclass of UITextView
that overrides the canPerformAction:withSender:
method to return NO
for actions that you don't want to allow:
- (BOOL)canPerformAction:(SEL)action withSender:(id)sender
{
if (action == @selector(paste:))
return NO;
return [super canPerformAction:action withSender:sender];
}
另见 UIResponder
这篇关于如何在UITextView中禁用复制,剪切,选择,全选的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文