Webview加载失败,出现以下错误
Domain=WebKitErrorDomain Code=102 "Frame load interrupted" UserInfo={NSErrorFailingURLStringKey=file://www..com, NSLocalizedDescription=Frame load interrupted, NSErrorFailingURLKey=file://www.website.com}
我的代码:
webView.frame = CGRect(x: 0, y: 0, width: self.view.frame.size.width, height: self.view.frame.size.height)
webView.delegate = self
let url = NSURL(string: "www.amazon.com")
let request = NSURLRequest(url: url as! URL)
webView.loadRequest(request as URLRequest)
view.addSubview(webView)
func webView(_ webView: UIWebView, shouldStartLoadWith request: URLRequest, navigationType: UIWebViewNavigationType) -> Bool {
return true
}
func webViewDidStartLoad(_ webView: UIWebView) {
print("webview is start loading")
}
func webViewDidFinishLoad(_ webView: UIWebView) {
print("webview is finish loading")
}
func webView(_ webView: UIWebView, didFailLoadWithError error: Error) {
print("webview loading error\(error)")
}