1

如何使用 WKWebView 加载 html 字符串。

我刚找到loadRequest方法。我能想到的唯一方法是将html字符串保存到文件中,然后通过NSURLRequest......加载它。

4

1 回答 1

3

在 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 字符串

于 2014-07-11T07:13:27.097 回答