views:

165

answers:

2

I have a webview as the detail view of a tableView navigation based app. There are "UP" and "DOWN" arrows on the navigationBar that the user can use to page through the different detail views.

Everything works fine as long as the user only clicks the "UP" or "Down" arrows once. But if the arrows are clicked multiple times and the loadRequest message is sent twice to the UIWebView, I get the error message "NSURLErrorDomain error -999" from my didFailLoadWithError method.

It seems like if a loadRequest is sent while the page is currently loading a view the error is sent. As long as the page is finished loading everything works fine.

I've tried a variety of solutions, all with the same result.

Thanks for the help!

A: 

I solved the problem by calling:

[self.myWebView stopLoading];
myWebView.delegate = nil;

before reloading the new URL. Before I send the new loadRequest I call:

myWebView.delegate = self;
Jonah
+1  A: 

I had the same problem today - try also this approach:

- (void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error {
  NSLog(@"didFail: %@ stillLoading:%@ error code:%i", [[webView request]URL], (webView.loading?@"NO":@"YES"), [error code]);
  if ([error code] != -999) {
    // Handle your other errors here
  }
}

Reference

Irene