func webView(_ webView: WKWebView, didStartProvisionalNavigation navigation: WKNavigation!) { if(isFirst){ webView.stopLoading() let sb = UIStoryboard(name: "Main", bundle:nil) let vc = sb.instantiateViewController(withIdentifier: "webView") as! WebViewController vc.url = String(describing: webView.url!) self.present(vc, animated: true, completion: nil) } }
注意红色字体部分,后面的感叹号不写不会报错和警告,但是运行出现闪退(具体原因不明),加上感叹号正常运行
webView 注意不能使用全局定义的变量