如何在 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.
推荐答案
禁用粘贴板操作的最简单方法是创建一个覆盖 canPerformAction:withSender:
UITextView 的子类code> 方法为您不想允许的操作返回 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屋!
查看全文