- (void)noLongTouch
{
//禁止长按弹出 UIMenuController 相关
//禁止选择 css 配置相关
NSStringcss = @"body{-webkit-user-select:none;-webkit-user-drag:none;}";
//css 选中样式取消
NSMutableStringjavascript = [NSMutableString string];
[javascript appendString:@"var style = document.createElement('style');"];
[javascript appendString:@"style.type = 'text/css';"];
[javascript appendFormat:@"var cssContent = document.createTextNode('%@');", css];
[javascript appendString:@"style.appendChild(cssContent);"];
[javascript appendString:@"document.body.appendChild(style);"];
[javascript appendString:@"document.documentElement.style.webkitUserSelect='none';"];//禁止选择
[javascript appendString:@"document.documentElement.style.webkitTouchCallout='none';"];//禁止长按
//javascript 注入
WKUserScript noneSelectScript = [[WKUserScript alloc] initWithSource:javascript
injectionTime:WKUserScriptInjectionTimeAtDocumentEnd
forMainFrameOnly:YES];
WKUserContentControlleruserContentController = [[WKUserContentController alloc] init];
[userContentController addUserScript:noneSelectScript];
WKWebViewConfiguration*configuration = [[WKWebViewConfiguration alloc] init];
configuration.userContentController = userContentController;
//控件加载
[self.myWebView.configuration.userContentController addUserScript:noneSelectScript];
}