1. Welcome to the new MacRumors forums. See our announcement and read our FAQ

UIWebView doesn't call didFailLoadWithError

Discussion in 'iPhone/iPad Programming' started by invano, Mar 1, 2012.

  1. macrumors newbie

    #1
    Hello everybody.
    I have a tabBarController project and i put an UIWebView on the first controller.
    It's all working except the didFailLoadWithError.

    Here it is the code

    myappFirstViewController.h



    Code:
    #import <UIKit/UIKit.h>
    
    @interface myappFirstViewController : UIViewController <UIWebViewDelegate> 
    
    @property (weak, nonatomic) IBOutlet UIWebView *MY_uiwebview;
    
    @end




    myappFirstViewController.m



    Code:
    #import "myappFirstViewController.h"
    
    @interface myappFirstViewController ()
    @end
    
    @implementation myappFirstViewController
    
    @synthesize MY_uiwebview;
    
    
    -(void)MY_uiwebview:(UIWebView *)MY_uiwebview didFailLoadWithError:(NSError *)error {
    
        NSLog(@"ERROR UIWEBVIEW");
    
        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Error" message:@"Connection error" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
    
        [alert show];
    
    }
    
    
    - (void)viewDidLoad
    
    {
        [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    }
    
    - (void)viewDidUnload
    
    {
        [self setMY_uiwebview:nil];
        [super viewDidUnload];
        // Release any retained subviews of the main view.
    
    }
    
    - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
    
    {
       return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown);
    }
    
    
    
    - (IBAction)Play {......etc..... }
    @end

    i cannot understand why (for example in AereoMode) it does not enter in
    Code:
     -(void)MY_uiwebview:(UIWebView *)MY_uiwebview didFailLoadWithError:(NSError *)error

    Thank you to everybody :)


    p.s I have the same problem with iAd and
    Code:
    -(void)bannerViewDidLoadAd:(ADBannerView *)banner {
    
    and also
    Code:
    -(void)bannerView:(ADBannerView *)banner didFailToReceiveAdWithError:(NSError *)error 
    p.s. I am using xCode 4.3
     
  2. macrumors 6502

    #2
    Are you sure that you've set up the delegate for your UIWebView?
     
  3. macrumors newbie

    #3
    here in the .h file

    Code:
    @interface myappFirstViewController : UIViewController <UIWebViewDelegate>
     
  4. macrumors 6502

    #4
    This code only tells the compiler that "myappFirstViewController" conforms to the UIWebViewDelegate protocol. It does not in anyway actually assign a delegate to the instance of your UIWebView.

    I would highly suggest reading the Apple's documentation on Protocols and the Delegate/Data Source patterns before continuing.
     
  5. macrumors newbie

    #5
    oh my god! I forgot the delegates!
    now it's working!

    thank you! and sorry for the oversight :eek:



    p.s. yeah you guessed it, i'm learning ...:)
     

Share This Page