今天遇到了第一次点击web浏览器没问题 ,第二次就崩溃
报错:WKWebView was deallocated while key value observers were still registered with it
因为控制器dealloc之前没有移除kvo
[self.webView addObserver:self
forKeyPath:@"title"
options:NSKeyValueObservingOptionNew
context:nil];
解决办法:
-(void)dealloc{
[_webView removeObserver:self forKeyPath:@"title"];
[[NSNotificationCenter defaultCenter] removeObserver:self];
}
网友评论