使用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里寫,一樣的。