UIWebView EXC_BAD_ACCESS crash

后端 未结 6 675
无人共我
无人共我 2020-12-13 00:49

I\'m experiencing crashes of an app that uses UIWebView. Usually it\'s when page is not fully loaded and UIWebView is sent stopLoading selector. Or when UIWebView fully load

6条回答
  •  佛祖请我去吃肉
    2020-12-13 01:25

    Handling unregistering the delegate from the webview, and stopping the webview from loading,is best handled from the ViewController's dealloc method.

    As an example of when viewWillDisappear can fail: if the ViewController is a child of another ViewController, you can trigger the removal of the ViewController's view from the parent ViewController's view with an animation. At the same time, you can remove the ViewController from its parent and nil out its reference. At that point the ViewController will be nil and viewWillDisappear will never be called, meaning the WebView delegate will never be cleaned up.

    Use dealloc and ensure that your WebView is always cleaned up.

提交回复
热议问题