PDA

View Full Version : UIWebView doesn't call didFailLoadWithError




invano
Mar 1, 2012, 01:34 PM
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



#import <UIKit/UIKit.h>

@interface myappFirstViewController : UIViewController <UIWebViewDelegate>

@property (weak, nonatomic) IBOutlet UIWebView *MY_uiwebview;

@end





myappFirstViewController.m



#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 -(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



ppilone
Mar 1, 2012, 01:40 PM
Are you sure that you've set up the delegate for your UIWebView?

invano
Mar 1, 2012, 01:44 PM
Are you sure that you've set up the delegate for your UIWebView?

here in the .h file

@interface myappFirstViewController : UIViewController <UIWebViewDelegate>

ppilone
Mar 1, 2012, 02:59 PM
here in the .h file

@interface myappFirstViewController : UIViewController <UIWebViewDelegate>

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.

invano
Mar 1, 2012, 03:38 PM
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.

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

thank you! and sorry for the oversight :o



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