![](/img/trans.png)
[英]Bundle.main.url(forResource: "AppleIncRootCertificate", withExtension: "cer") == nil
[英]Bundle.main.url(forResource: “hello”, withExtension: “html”) is returning nil
我創建了hello.html文件。嘗試訪問該文件時,url每次都返回nil。
override func viewDidLoad() {
super.viewDidLoad()
if let url = Bundle.main.url(forResource: "hello", withExtension: "html"){
if let htmlData = try? Data(contentsOf:url){
let baseURL = URL(fileURLWithPath: Bundle.main.bundlePath)
webView.load(htmlData, mimeType: "text/html", textEncodingName: "UTF-8", baseURL: baseURL)
}
}
// Do any additional setup after loading the view.
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.