webview使用遇到 It is possible that this object was over-released, or is in the process of deallocation错误的解决办法

使用wekwebview时,push后,再pop返回,报错了:

Cannot form weak reference to instance (xxxx) of class xxxx. It is possible that this object was over-released, or is in the process of deallocation.


解决方案:

1. 不要在 dealloc 方法中,使用 weak self

2. A控制器(包含scrollView及其子类,并设置了其代理),B控制器(webView,并设置了webView.scrollView.delegate = self),当A push 到 B,然后B pop回 A时,会引起程序崩溃。解决方案就是再B将要退出时把webView.scrollView.delegate = nil

我用第二种办法解决了,在deinit添加如下

deinit{
    wkWebView.scrollView.delegate = nil

}

如果是oc,就在deallco里写,一样的。

 

原文地址:https://www.cnblogs.com/yajunLi/p/6478868.html