ios wkwebview 跳转到新的controllerview加载页面 出现闪退问题

 

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 注意不能使用全局定义的变量
posted @ 2017-10-08 15:15  荣超  阅读(1488)  评论(0编辑  收藏  举报