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

    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


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


    #import "myappFirstViewController.h"
    @interface myappFirstViewController ()
    @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..... }

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

    Thank you to everybody :)

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

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

    here in the .h file

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

    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

    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