I had a problem with iAd integration in iPhone applications - an ad in a banner is great when it is spent (see http://www.clingmarks.com/iAd1.png and http://www.clingmarks.com/iAd2.png ), however, when I close it, it left a white blank screen (see http://www.clingmarks.com/iAd3.png ). I could not understand why. This is how I integrate the ad:
Since I need to support other ads for the lower version of iPhone OS, I add a container view at the top of the applications whose view controller is AdViewController. When the view is loaded, I create AdBannerView programmatically and add it as a subview in AdViewController.view. Here is the code in the viewDidLoad method:
Class adClass = (NSClassFromString(@"ADBannerView"));
if (adClass != nil) {
iAdView = [[ADBannerView alloc] initWithFrame:CGRectZero];
iAdView.frame = CGRectOffset(iAdView.frame, 0, -50);
iAdView.requiredContentSizeIdentifiers = [NSSet setWithObject:ADBannerContentSizeIdentifier320x50];
iAdView.currentContentSizeIdentifier = ADBannerContentSizeIdentifier320x50;
iAdView.delegate = self;
iadViewIsVisible = NO;
[self.view addSubview:iAdView];
} else {
}
The following are delegate methods:
enter code here
- (void)bannerViewDidLoadAd:(ADBannerView *)banner {
if (!iadViewIsVisible) {
[UIView beginAnimations:@"animateAdBannerOn" context:NULL];
banner.frame = CGRectOffset(banner.frame, 0, 50);
[UIView commitAnimations];
iadViewIsVisible = YES;
}
}
- (void)bannerView:(ADBannerView *)banner didFailToReceiveAdWithError:(NSError *)error {
if (iadViewIsVisible) {
[UIView beginAnimations:@"animateAdBannerOff" context:NULL];
banner.frame = CGRectOffset(banner.frame, 0, -50);
[UIView commitAnimations];
iadViewIsVisible = NO;
}
}
source
share