I’m trying to avoid the problem generated while UIWebView‘s delegate returns an error like that. I have the common workaround (I saw it anywhere in the Internet) in my delegate implementation
- (void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error {
if ([error code] == NSURLErrorCancelled) return;
}
The problem I have is that this does not works always. Sometimes loads the web, another times loads parts of the web (the header, a part of the text…) and several times does not load anything.
Is there any other solution to this? Exists any open source implementation of a browser that works properly?
From Apple docs:
So, the most likely case for this to happen is for you to load a request and then another one (or the same one), before the first one is completed. This can happen. e.g., if you call
loadRequest(orloadHTMLString) in a method likeviewDidAppear:that can be called multiple times. This has also been reported to happen if you quickly tap 2 links in theUIWebView.So, the general suggestion is to review how and where you call
loadRequest(orloadHTMLString), and possibly provide some code.In order to troubleshoot this, I would suggest to add the following traces to your web view delegate:
If you inspect the output, you should see more clearly what is going on. If you paste the output, we could try and help you further.