I have implimented the iAd code, however both on the simulator and on my device it likes to make the iAd disappear after a while, even when the internet connection is fine. Is there something that I did wrong with my implementation, or is this just expected? Below is both the code, and the Console that shows how often both are being called. Thanks!
- (void)viewDidLoad {
adView = [[ADBannerView alloc] initWithFrame:CGRectZero];
adView.frame = CGRectOffset(adView.frame, 0, 435); //orginally -50
adView.requiredContentSizeIdentifiers = [NSSet setWithObject:ADBannerContentSizeIdentifier320x50];
adView.currentContentSizeIdentifier = ADBannerContentSizeIdentifier320x50;
[self.view addSubview:adView];
adView.delegate = self;
self.bannerIsVisible = NO;
[super viewDidLoad];
}
- (void)bannerViewDidLoadAd:(ADBannerView *)banner {
NSLog(@"bannerViewDidLoadAd");
if (!self.bannerIsVisible)
{
[UIView beginAnimations:@"animateAdBannerOn" context:NULL];
// banner is invisible now and moved out of the screen on 50 px
banner.frame = CGRectOffset(banner.frame, 0, -25); //orginally 50
[UIView commitAnimations];
self.bannerIsVisible = YES;
}
}
- (void)bannerView:(ADBannerView *)banner didFailToReceiveAdWithError:(NSError *)error {
NSLog(@"bannerViewRecievedError");
if (self.bannerIsVisible)
{
[UIView beginAnimations:@"animateAdBannerOff" context:NULL];
// banner is visible and we move it out of the screen, due to connection issue
banner.frame = CGRectOffset(banner.frame, 0, 25); //orginally -50
[UIView commitAnimations];
self.bannerIsVisible = NO;
}
}
- (void)dealloc {
NSLog(@"dealloc");
adView.delegate=nil;
[adView release];
[super dealloc];
}
Heres what the console says:
2010-12-29 20:04:17.717 app[48943:207] bannerViewRecievedError
2010-12-29 20:04:52.410 app[48943:207] bannerViewRecievedError
2010-12-29 20:05:17.168 app[48943:207] bannerViewDidLoadAd
2010-12-29 20:05:47.166 app[48943:207] bannerViewDidLoadAd
2010-12-29 20:06:16.993 app[48943:207] bannerViewRecievedError
2010-12-29 20:06:46.803 app[48943:207] bannerViewDidLoadAd
2010-12-29 20:07:17.314 app[48943:207] bannerViewDidLoadAd
2010-12-29 20:07:47.140 app[48943:207] bannerViewRecievedError
2010-12-29 20:08:19.899 app[48943:207] bannerViewRecievedError
2010-12-29 20:08:46.978 app[48943:207] bannerViewDidLoadAd
2010-12-29 20:09:17.106 app[48943:207] bannerViewRecievedError
2010-12-29 20:09:46.930 app[48943:207] bannerViewDidLoadAd
2010-12-29 20:10:17.114 app[48943:207] bannerViewDidLoadAd
2010-12-29 20:10:47.609 app[48943:207] bannerViewDidLoadAd