简体   繁体   中英

WKWebView localHTMLString doesn't seem to work on iOS 8.4

I have a very simple call in my WKWebView and nothing is displayed

   webView.loadHTMLString("<html><body>test</body></html>", baseURL: nil)

If I replace this with , WKWebView renders the web Page fine

  webView.loadRequest(NSURLRequest(url: NURL("www.bing.com"))

Any reason why loadHTMLString is not able to render a very simple HTML string? I know there are limitations of WKWebView from rendering local files, but this is the html string and I can't imaging what I am doing wrong

In the navigationDelegate method

func webView(webView: WKWebView, decidePolicyForNavigationAction navigationAction: WKNavigationAction, decisionHandler: ((WKNavigationActionPolicy) -> Void)) { }

I was returning decisionHandler(.Cancel) if the scheme isn't http. For loadHTMLString, scheme is returned as "" and hence the navigation was being cancelled

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM