Note that there are some explanatory texts on larger screens.

plurals
  1. POUIWebView crashing only on second load
    text
    copied!<p>Ok I've got a dreaded EXC_BAD_ACCESS that I can't seem to track down but it only occurs on my second load of a UIWebView. I've searched and reviewed all the similar issues on SO and tried a few different approaches but I'm still struggling.</p> <p>Here is the program flow that finally loads the WebView.</p> <p>I have a Table View which lists videos. When a row is clicked a Detail View loads, with more info. about the video. Once the detail view is loaded, if the user clicks Play another view loads that has the WebView.</p> <p>In this view, on viewDidLoad the NSURLRequest is created and passed to the WebView loadRequest.</p> <p>The WebView loads fine and displays the webpage with the video I need. All of this is on a navigation controller so the user can click Back and returns to the previous detail view.</p> <p>I am releasing the WebView in the dealloc and also stopping it from loading if it was still doing that. The WebView is obtained via an IBOutlet and is synthesized as (nonatomic,retain).</p> <p>I have NSZombiesEnabled and didn't see any issues there. So when does it crash? If the user clicks Play a second time, the video View is created again and on the [webView loadRequest] - I get a EXC_BAD_ACCESS once the page has loaded.</p> <p>Here is the kicker though, if I go back to the Table and pick another row (video), then I can load that WebView without any problems. It is only if I load the same video twice that it crashes.</p> <p>The view that holds the WebView is released after being created and pushed on the nav. controller. I setup a ton of break points - everything (on the second load) is good right up until the webViewDidFinishLoad is called, whatever happens after that is causing the crash. I don't get a stack trace (or don't know how to find it) :)</p> <p>Thanks!</p> <p>Here is the code from the WebView view - some of this was based on other peoples findings of memory issues with UIWebView.</p> <pre><code> - (void)viewDidLoad { [super viewDidLoad]; self.title = @"Video Player"; NSURL *url = [NSURL URLWithString:video.url]; NSURLRequest *request = [NSURLRequest requestWithURL:url]; [webView loadRequest:request]; } - (void)viewDidUnload { [super viewDidUnload]; [webView setDelegate:nil]; [self setWebView:nil]; } - (void)dealloc { [video release]; [super dealloc]; } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload