本文主要是介绍iOS WKWebView 禁止长按(超链接、图片、文本...)弹出效果,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
方法一:
//设置代理
self.wkWebView.navigationDelegate = self;#pragma mark - wkWebViewDelegate
//禁止链接跳转
- (void)webView:(WKWebView *)webView decidePolicyForNavigationAction:(WKNavigationAction *)navigationAction decisionHandler:(void (^)(WKNavigationActionPolicy))decisionHandler {NSLog(@"navigationAction = %@, request = %@",navigationAction,navigationAction.request.URL);if ([navigationAction.request.URL.scheme containsString:@"http"]) {decisionHandler(WKNavigationActionPolicyCancel);} else {decisionHandler(WKNavigationActionPolicyAllow);}
}
方法二:
//WKWebview 禁止长按(超链接、图片、文本...)弹出效果[self.webView evaluateJavaScript:@"document.documentElement.style.webkitTouchCallout='none';" completionHandler:nil];[self.webView evaluateJavaScript:@"document.documentElement.style.webkitUserSelect='none';"completionHandler:nil];
君凯商联网-iOS-字唐名僧
这篇关于iOS WKWebView 禁止长按(超链接、图片、文本...)弹出效果的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!