UIWebView in multithread ViewController

前端 未结 8 867
日久生厌
日久生厌 2020-12-24 09:38

I have a UIWebView in a viewcontroller, which has two methods as below. The question is if I pop out(tap back on navigation bar) this controller before the second thread is

8条回答
  •  滥情空心
    2020-12-24 10:02

    I'm not sure exactly what's going based on your code, but it looks like viewDidAppear is getting called and creating the second thread, and then you're navigating away from the controller and releasing it, and then the second thread finishes and calls performSelectorOnMainThread on the released object "self". I think you may just need to check that the release has not occurred?

    The error message you're getting implies that you're running some UIKit code from your second thread. Apple recently added some checks for threaded calls to UIKit, and I think you probably just need to refactor your load function to update the UI on the main thread, instead of calling UIWebView functions from the second thread.

    Hope that helps!

提交回复
热议问题