loadData:MIMEType:textEncodingName:baseURL: in WKWebView

谁说胖子不能爱 提交于 2019-12-10 16:47:42

问题


I'd like to use WKWebView instead of a UIWebView to display data on iOS. However, it seems that loadData:MIMEType:textEncodingName:baseURL: was removed in WKWebView.

Is there any way to mimic this functionality in WKWEbView?

Thanks!


回答1:


You could convert your NSData to NSString and use loadHTMLString:baseURL: (API Docs).

However, that method has issues with file-system base URLs in the latest beta: WKWebView not working in iOS 8 beta 4.




回答2:


As of iOS 9.0 and onwards WKWebView now has the same method:

- loadData:MIMEType:characterEncodingName:baseURL:

That said, I'm currently having issues with certain file types (MS Word) that worked in UIWebView but not in WKWebView.



来源:https://stackoverflow.com/questions/25799977/loaddatamimetypetextencodingnamebaseurl-in-wkwebview

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!