WkWebView does not load links to pdfs

前端 未结 5 1215
情书的邮戳
情书的邮戳 2020-11-30 15:41

The WKWebView is not loading links. I am linking users to a privacy policy page, and the page has a group of links. The links are all pdfs hosted by wix. On safari and Chrom

5条回答
  •  再見小時候
    2020-11-30 15:58

    First you should add this to your delegate:

    func webView(_ webView: WKWebView, decidePolicyFor navigationAction: WKNavigationAction, decisionHandler: @escaping (WKNavigationActionPolicy) -> Void) {
         decisionHandler(WKNavigationActionPolicy.allow)
    }
    

    Then you may also need to implement the following method if the link has target="_blank"

    func webView(_ webView: WKWebView, createWebViewWith configuration: WKWebViewConfiguration, for navigationAction: WKNavigationAction, windowFeatures: WKWindowFeatures) -> WKWebView? {
    

提交回复
热议问题