美文网首页
Swift闪退Cannot remove an observer

Swift闪退Cannot remove an observer

作者: 玉思盈蝶 | 来源:发表于2020-07-09 16:10 被阅读0次

目前我试了是没问题,但是看Bugly后台崩溃率还挺高的,暴力处理下吧。

override func viewDidLoad() {
    super.viewDidLoad()
    setupSubviews()
    if let url = URL(string: self.urlStr) {
        self.webView.load(URLRequest(url: url))
    }
    webView.addObserver(self, forKeyPath: #keyPath(WKWebView.estimatedProgress), options: .new, context: nil)
    isViewDidLoad = true
}
deinit {
    if isViewDidLoad {
        webView.removeObserver(self, forKeyPath:  #keyPath(WKWebView.estimatedProgress))
    }
}

参考链接:

https://blog.csdn.net/chokshen/article/details/86304028

https://www.jianshu.com/p/b4e95da41ce5

PS:你们有遇到这个问题吗?怎么解决的?本来打算用try catch,但是不能catch住,所以。。。。。。知道的求告知呀!

相关文章

网友评论

      本文标题:Swift闪退Cannot remove an observer

      本文链接:https://www.haomeiwen.com/subject/ozdscktx.html