Note that there are some explanatory texts on larger screens.

plurals
  1. POApp crashes at [UIWebView webView:didReceiveTitle:forFrame:]
    text
    copied!<p>I am implementing a simple in-app browser. In my home view (<code>UITableViewController</code>), I have something like: </p> <pre><code> - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { WebViewController *webViewController = [[WebViewController alloc] init]; switch (indexPath.row) { case 0: webViewController.stringURL = @"http://www.google.com"; break; case 1: webViewController.stringURL = @"http://www.bing.com"; break; default: webViewController.stringURL = @"http://stackoverflow.com"; break; } [self.navigationController pushViewController:webViewController animated:YES]; [webViewController release]; } </code></pre> <p>The app <em>crashed</em> after I repetitively navigated back and forth between my home view and <code>webViewController</code>a few times.</p> <p>Inside <code>WebViewController</code> class, I have nothing but a <code>[UIWebView *webView]</code> and a <code>[UIActivityIndicatorView *activityIndicator]</code>. Both are with attributes <code>nonatomic, retain</code>. Here is the implementation. </p> <pre><code> #import "WebViewController.h" @implementation WebViewController @synthesize webView, activityIndicator, stringURL; - (void)dealloc { [self.webView release]; self.webView.delegate = nil; [self.activityIndicator release]; [super dealloc]; } -(void)loadView { UIView *contentView = [[UIView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame]]; self.view = contentView; CGRect webFrame = [[UIScreen mainScreen] applicationFrame]; webFrame.origin.y = 0.0f; self.webView = [[UIWebView alloc] initWithFrame:webFrame]; self.webView.backgroundColor = [UIColor blueColor]; self.webView.scalesPageToFit = YES; self.webView.autoresizingMask = (UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight); self.webView.delegate = self; [self.view addSubview: self.webView]; [self.webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:self.stringURL]]]; self.activityIndicator = [[UIActivityIndicatorView alloc]initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray]; self.activityIndicator.frame = CGRectMake(0.0, 0.0, 30.0, 30.0); self.activityIndicator.center = self.view.center; [self.view addSubview: self.activityIndicator]; } - (void)viewDidLoad { [super viewDidLoad]; [self loadView]; } - (void)webViewDidStartLoad:(UIWebView *)webView { // starting the load, show the activity indicator in the status bar [UIApplication sharedApplication].networkActivityIndicatorVisible = YES; [activityIndicator startAnimating]; } - (void)webViewDidFinishLoad:(UIWebView *)webView { // finished loading, hide the activity indicator in the status bar [UIApplication sharedApplication].networkActivityIndicatorVisible = NO; [activityIndicator stopAnimating]; } @end </code></pre> <p><br /></p> <p> I just ran my app in Instruments using the <em>Zombies template</em>, which shows <code>-[UIWebView webView:didReceiveTitle:forFrame:]</code> is the Zombie call. But I still can&#8217;t figure out what is actually the problem. <p> (Please download <a href="http://dl.dropbox.com/u/2320244/crash.trace.zip" rel="nofollow">trace</a> if needed) </p> Any help is greatly appreciated!</p> <p><br /> <p>[Update]:<br /><br /></p> <ol> <li>As @7KV7 and @David pointed out, there is an obvious bug in my <code>dealloc</code> function. I should call <code>self.webView.delegate=nil;</code> first before I release <code>self.webView</code>. Sorry about that. Unfortunately, after I fix it, the app still crashes in the same way. </li> <li>If I delete <code> [webViewController release]; </code> from the first code block, the crash actually is gone. But obviously, there will be memory leak.</li> </ol>
 

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