UIWebView delegate method shouldStartLoadWithRequest: equivalent in WKWebView?

前端 未结 7 830
忘掉有多难
忘掉有多难 2020-12-12 14:37

I have a module inside my iOS 7+ app which is a UIWebView. The html page loads a javascript that creates custom-shaped buttons (using the Raphaeljs library). With UIWebView,

相关标签:
7条回答
  • 2020-12-12 15:13

    for swift 4.2: (taking from Yifei He 何一非. )

     func webView(_ webView: WKWebView, decidePolicyFor navigationAction: WKNavigationAction, decisionHandler: (WKNavigationActionPolicy) -> Void) {
    
            let url = navigationAction.request.url
            let urlStr = url?.absoluteString
            switch urlStr {
            case BASE_URL:
                //self.someFunc()
                decisionHandler(.cancel)
                break
            default:
                decisionHandler(.allow)
                break
            }
    
        }
    
    0 讨论(0)
提交回复
热议问题