Search code examples
iphoneobjective-cuiwebviewuiwebviewdelegate

Is didFailLoadWithError normally called after I return NO in the delegate function shouldStartLoadWithRequest?


I am seeing this behavior not documented in Apple's UIWebViewDelegate:

If I return NO to the delegate function

- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType {

This function is immediately called with the error 101 (This URL cannot be loaded.).

- (void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error {

Since I explicitly cancelled the request, is it even normal for didFailLoadWithError to be invoked?


Solution

  • Update: UIWebView will NOT call didFailLoadWithError if you manually cancel the connection.

    I've verified this with testing. The reason why didFailLoadWithError is for something else completely unrelated to UIWebView.