开发者

Sending loadRequest messages to UIWebView before current view is finished loading causes error

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!


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


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;
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜