Reputation: 8327
This is my first iAd for iPhone.
In development mode, if I switch my iPhone to airport mode, my app being debugged never ever gets this event.
But, if I start app with airport off, I get the 'bannerViewDidLoadAd' event okay. And if airport turned on -- never get didFailToReceiveAdWithError.
@interface ViewController : UIViewController <ADBannerViewDelegate> {
ADBannerView* adView;
}
@property(nonatomic, retain) IBOutlet ADBannerView *adView;
...
- (void)viewDidLoad
{
... (adView is from Interface Builder )
adView.requiredContentSizeIdentifiers = [NSSet setWithObject:ADBannerContentSizeIdentifier320x50];
adView.currentContentSizeIdentifier = ADBannerContentSizeIdentifier320x50;
[self.view addSubview:adView];
adView.delegate=self;
[super viewDidLoad];
}
- (void)bannerViewDidLoadAd:(ADBannerView *)banner
{
NSLog(@"bannerViewDidLoadAd");
if ( adView.hidden )
{
NSLog(@"going visible");
[UIView beginAnimations:@"animateAdBannerOn" context:NULL];
adView.hidden = NO;
// banner is invisible now and moved out of the screen on 50 px
//banner.frame = CGRectOffset(banner.frame, 0, 50);
[UIView commitAnimations];
}
}
- (void)bannerView:(ADBannerView *)banner didFailToReceiveAdWithError:(NSError *)error
{
NSLog(@"didFailToReceiveAdWithError");
if( !adView.hidden ) // ad banner displayed, but lost ad network
{
NSLog(@"going hidden");
[UIView beginAnimations:@"animateAdBannerOff" context:NULL];
adView.hidden = YES;
// banner is visible and we move it out of the screen, due to connection issue
//banner.frame = CGRectOffset(banner.frame, 0, -50);
[UIView commitAnimations];
}
}
Upvotes: 0
Views: 1336
Reputation: 890
If you check the Apple Developer Documentation you notice you have 2 options:
Take into account that you can't turn off wireless for the iOS simulator. You need to disable the network connection of your development system:
IPhone Connectivity Testing: How do I force it to lose connection?
Upvotes: 0
Reputation: 688
The only time
- (void)bannerView:(ADBannerView *)banner didFailToReceiveAdWithError:(NSError *)error
is called is when an ad is already displayed and receives an error. When you are in airplane mode the initial ad is never displayed therefore this method is not called.
*Edit for clarity
Upvotes: 2