在 ios uiwebview 上禁用特定的 link

disable a specific link on ios uiwebview

如何禁用 iOS uiwebview 上的特定 link? 在 webview 中加载的页面可以有数千 urls 但我想禁用一个 url.

我觉得我必须使用这种方法来工作。但是想不通。

 func webView(webView: UIWebView, shouldStartLoadWithRequest request: NSURLRequest, navigationType: UIWebViewNavigationType) -> Bool {
}

我正在与 objective-c 合作。抱歉,如果我的 swift 代码有误。我希望你明白逻辑。

试试吧。

 func webView(_ webView: UIWebView, shouldStartLoadWithRequest request: NSURLRequest, navigationType: UIWebViewNavigationType) -> Bool {

   let surl = request.url?.absoluteString

   if surl == "http://disableurl.com" {
      return false;
   }      
   return true;
 }