[英]Bundle.main.url(forResource: “hello”, withExtension: “html”) is returning nil
I have created hello.html file .when I am try to access it,url is returning nil everytime. 我创建了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.