简体   繁体   English

WKWebView localHTMLString似乎在iOS 8.4上不起作用

[英]WKWebView localHTMLString doesn't seem to work on iOS 8.4

I have a very simple call in my WKWebView and nothing is displayed 我在WKWebView中打了一个非常简单的电话,没有任何显示

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

If I replace this with , WKWebView renders the web Page fine 如果将其替换为,则WKWebView可以使网页正常显示

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

Any reason why loadHTMLString is not able to render a very simple HTML string? 为什么loadHTMLString无法呈现非常简单的HTML字符串? 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 我知道从呈现本地文件到WKWebView都有局限性,但这是html字符串,我无法想象自己做错了什么

In the navigationDelegate method 在navigationDelegate方法中

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

I was returning decisionHandler(.Cancel) if the scheme isn't http. 如果方案不是http,我将返回DecisionHandler(.Cancel)。 For loadHTMLString, scheme is returned as "" and hence the navigation was being cancelled 对于loadHTMLString,方案返回为“”,因此导航被取消了

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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