2

I see the following message and no webpage while trying to load a valid URL :

delegate (webView:decidePolicyForNavigationAction:request:frame:decisionListener:) failed to return after waiting 10 seconds. main run loop mode: kCFRunLoopDefaultMode

Can anyone kindly help me out ?

Using: iPad 2 on iOS 4.x

Comment: It seems to be fine on iOS 5.x

Code Used:

    newsWebView=[[UIWebView alloc] initWithFrame:CGRectMake(0.0, 0.0, self.view.bounds.size.width, self.view.bounds.size.height-50.0-adHeight)];
    newsWebView.dataDetectorTypes = UIDataDetectorTypeAll;
    newsWebView.backgroundColor=[UIColor blackColor];
    [newsWebView setScalesPageToFit:YES];
    [self.view addSubview:newsWebView];
    newsWebView.delegate=self;
    [self webViewLoadRequest];


- (void)webViewLoadRequest 
{
    NSURL *url = [NSURL URLWithString:urlAddress];
    NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];
    [newsWebView loadRequest:requestObj];
}

//Delegate

- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType {
    return YES;
}

- (void)webViewDidStartLoad:(UIWebView *)webView {  

}

- (void)webViewDidFinishLoad:(UIWebView *)webView 
{
    CGFloat scale=newsWebView.contentScaleFactor;
    NSString *jsCommand = [NSString stringWithFormat:@"document.body.style.zoom = %f;",scale];
    [newsWebView stringByEvaluatingJavaScriptFromString:jsCommand];

    [rightButton setEnabled:YES];

    if(titleStatus==1){
        self.title=[newsWebView stringByEvaluatingJavaScriptFromString:@"document.title"];
    }
} 

- (void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error
{
    if (error.code == 101) {

        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Cannot Open Page"
                                                        message:[error localizedDescription] delegate:nil
                                              cancelButtonTitle:@"Dismiss" otherButtonTitles:nil];
        [alert show];
        [alert release];

    } else if (error.code == -1003) {

        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Cannot Open Page"
                                                        message:@"Server cannot be found." delegate:nil
                                              cancelButtonTitle:@"Dismiss" otherButtonTitles:nil];
        [alert show];
        [alert release];

    } else if (error.code == -1009) {

        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Cannot Open Page"
                                                        message:@"No network connection." delegate:nil
                                              cancelButtonTitle:@"Dismiss"      otherButtonTitles:nil];
        [alert show];
        [alert release];

    } else if (error.code == -999) {
        // user probably stopped the web loading
    } else {
        NSLog(@"Error: %@", error.description);
    }
}
Ahsan
  • 2,964
  • 11
  • 53
  • 96

2 Answers2

0

I dont see u setting the WebViews delegate anywhere.. If ure creating the WebView in code then you should set its delegate and implement it..

Add the following line while setting up the WebView

     [newsWebViewNews setDelegate:self];

and implement <UIWebViewDelegate> in the class header file.

Mr.Anonymous
  • 820
  • 2
  • 13
  • 22
0

I created a exemple for you try this https://www.dropbox.com/s/lch00t0vjrydg77/ActivityIndicator.zip

Claudia Mardegan
  • 567
  • 4
  • 14