WKWebView does load resources from local document folder

后端 未结 8 519
伪装坚强ぢ
伪装坚强ぢ 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)
    }
    
    0 讨论(0)
  • 2020-11-28 10:36

    This solution helped me:

    [configuration.preferences setValue:@YES forKey:@"allowFileAccessFromFileURLs"];
    
    0 讨论(0)
提交回复
热议问题