如何在iOS uiwebview上禁用特定链接? 在webview中加载的页面可以有数千个网址,但我想禁用一个网址。
我感觉我必须使用这种方法进行工作。但无法弄清楚。
func webView(webView: UIWebView, shouldStartLoadWithRequest request: NSURLRequest, navigationType: UIWebViewNavigationType) -> Bool {
}
答案 0 :(得分:2)
我正在使用objective-c。对不起,如果我的快速代码错了。我希望你理解逻辑。
试试吧。
func webView(_ webView: UIWebView, shouldStartLoadWithRequest request: NSURLRequest, navigationType: UIWebViewNavigationType) -> Bool {
let surl = request.url?.absoluteString
if surl == "http://disableurl.com" {
return false;
}
return true;
}