Question

I have a UIWebView that works ok. The delegate is working. When I open a URL, events shouldStartLoadWithRequest and webViewDidFinishLoad are fired.

But when for example I click on a Google search result, only shouldStartLoadWithRequest is fired, and webViewDidFinishLoad is never called.

This is causing problems because if I put a "loading..." indicator on shouldStartLoadWithRequest, in these cases the indicator still remains even after the page is correctly loaded.

Any idea why this is happening?

Was it helpful?

Solution 4

Not an expert on Google API, but as I suspected this might be your reason.

OTHER TIPS

in .h file add <UIWebViewDelegate>

and in .m:

yourWebview=[[UIWebView alloc]init];
yourWebview.delegate=self;

When you click on search, the navigationType is UIWebViewNavigationTypeFormSubmitted. So in this case, the return type should be YES. If it is not, webViewDidFinishLoad method is not fired.

- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType
{
    NSLog(@"shouldStartLoadWithRequest");

    if ( navigationType == UIWebViewNavigationTypeLinkClicked ){
        NSLog(@"UIWebViewNavigationTypeLinkClicked");

        return YES;
    } 
    if (navigationType ==UIWebViewNavigationTypeFormSubmitted ) {
        NSLog(@"UIWebViewNavigationTypeFormSubmitted");
        return YES;
    }
    if (navigationType ==UIWebViewNavigationTypeBackForward) {
        NSLog(@"UIWebViewNavigationTypeBackForward");
        return YES;
    }
    if (navigationType ==UIWebViewNavigationTypeFormResubmitted) {
        NSLog(@"UIWebViewNavigationTypeFormResubmitted");
        return YES;
    }
    if (navigationType ==UIWebViewNavigationTypeReload) {
        NSLog(@"UIWebViewNavigationTypeReload");
        return YES;
    }



    return YES;
}

This problem is usually found on ipad applications .... but you can solve your problem by using [self performselector:afterdelay] , you have to check in selector method whether webview has loaded or not using [m_pWebview loaded]; and according to that perform indicator stopping .... it's not the proper solution but it works .......

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top