【发布时间】:2018-01-29 18:26:56
【问题描述】:
我从网上下载了我的网站以存储在带有子文件夹的 xcode 项目中,并希望在本地 WKWebView 中运行。我发现 webview 加载的网页错过了所有 CSS/JS/Images 资源。我在互联网上搜索,但仍然无法正常工作。相对 url 中的网页是否不正确或我的代码获取 Main Bundle 位置问题?任何人都可以提供帮助。谢谢。
我写了这段代码来加载 WKWebView
let htmlFile = Bundle.main.path(forResource: "provisiontech", ofType: "htm")
let html = try? String(contentsOfFile: htmlFile!, encoding: String.Encoding.utf8)
let baseURL = Bundle.main.resourceURL!.appendingPathComponent("pvtc")
webView.loadHTMLString(html!, baseURL: baseURL)
【问题讨论】:
标签: ios xcode swift3 wkwebview