我创建了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.
}