在我的应用程序中,我想禁用UIWebView对象显示的内容的复制/粘贴/剪切.为此,我创建了一个UIWebView子类并覆盖了该- (BOOL)canPerformAction:(SEL)action withSender:(id)sender方法:
#pragma mark - UIResponderStandardEditActions
- (BOOL)canPerformAction:(SEL)action withSender:(id)sender {
if (action == @selector(copy:) ||
action == @selector(paste:)||
action == @selector(cut:)) {
return _copyCutAndPasteEnabled;
}
return [super canPerformAction:action withSender:sender];
}
Run Code Online (Sandbox Code Playgroud)
现在用户不再可以进行此类操作,但UIWebView仍显示"选择矩形",如以下屏幕截图所示:

注意:UIWebView中显示的内容不是HTML页面.我正在显示文件文件(PDF,DOC,PPT),使用以下文件从文件加载:
NSURL *fileURL = [NSURL fileURLWithPath:<document file path..>];
NSURLRequest *fileRequest = [NSURLRequest requestWithURL:fileURL];
[<uiwebView> loadRequest:fileRequest];
Run Code Online (Sandbox Code Playgroud)
有没有办法禁用/隐藏这个选择矩形功能?
[] S,