如何使用 WKWebView 加载 html 字符串。
我刚找到loadRequest
方法。我能想到的唯一方法是将html字符串保存到文件中,然后通过NSURLRequest
......加载它。
在 beta 3 中,我在 WKWebView 中找到了这个
/*! @abstract Sets the webpage contents and base URL.
@param string The string to use as the contents of the webpage.
@param baseURL A URL that is used to resolve relative URLs within the document.
@result A new navigation.
*/
func loadHTMLString(string: String!, baseURL: NSURL!) -> WKNavigation!
因此,您可以像使用 UIWebView 一样加载 html 字符串