EXC_BAD_ACCESS in UIWebView

后端 未结 5 786
囚心锁ツ
囚心锁ツ 2020-12-23 10:05

I just downloaded the crash reports for one of my iPhone apps from iTunes Connect. The most common crash has a trace like the following:

Exception Type:  EX         


        
相关标签:
5条回答
  • 2020-12-23 10:35

    I had a similar problem. I was using:

     [webView loadHTMLString:str baseURL:tmpUrl];
    
     [str release];
    

    The release of "str" caused the error message "EXC_BAD_ACCESS"

    0 讨论(0)
  • 2020-12-23 10:41

    Take a harder look inside the thing in your code that is implementing the UIWebViewDelegate protocol. In particular you want to look at whatever is handling webViewDidFinishLoad: You are trying to access a variable that's been released. Post the full source if you can, that will help us find it for you.

    0 讨论(0)
  • 2020-12-23 10:46

    I recently had a similar problem where my apps were crashing randomly. Turns out the problem was in using "onclick=" in the loaded HTML.

    Replaced the onclick with simple <a href="javascript:some_script"> and the problem went away.

    Hope this helps others who are experiencing the same issue with webviews.

    0 讨论(0)
  • 2020-12-23 10:50

    The scenario goes something like this:

    1. User enters screen with UIWebView. The UIViewController sets self as the delegate
    2. Web page starts downloading
    3. User exits screen
      3a. UIViewController gets deallocated
    4. UIWebView finishes loading and sends "I finished" message to its delegate...

    You need to stop the UIWebView from loading its page and sets its delegate to nil before you deallocate the delegate.

    0 讨论(0)
  • 2020-12-23 10:55

    It's almost 100% an error in your code. Errors in the iPhone SDK are quite rare and UIWebView has been tested quite good by many other developers.

    EXC_BAD_ACCESS occurs usually when you try to access an already released object. Obviously if Apple's code is trying to do that you are the one who has released the object wrongly. Are you sure you don't have a -autorelease or -release too much?

    0 讨论(0)
提交回复
热议问题