WKWebView does load resources from local document folder

后端 未结 8 580
伪装坚强ぢ
伪装坚强ぢ 2020-11-28 09:38

In my Swift iOS app, I want to download some dynamic HTML pages from a remote server, save them in the document directory, and display those pages from document directory.

8条回答
  •  暖寄归人
    2020-11-28 10:26

    This works nicely with file URL or remote URL, and whether file is in the bundle or in documents:

    if url.isFileURL {
        webView.loadFileURL(url, allowingReadAccessTo: url)
    } else {
        let request = URLRequest(url: url)
        webView.load(request)
    }
    

提交回复
热议问题