相关疑难解决方法(0)

显示文档时没有复制/粘贴和选择矩形的UIWebView

在我的应用程序中,我想禁用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,

iphone selection uiwebview ipad uiresponder

6
推荐指数
1
解决办法
1万
查看次数

标签 统计

ipad ×1

iphone ×1

selection ×1

uiresponder ×1

uiwebview ×1