With a few small tweaks to our view and code, we can animate our banner on and off the screen, depending on the availability of ads:
1. Open the demo project, or your own project containing an Ad Banner View, in Xcode. Open the main controller file for your view, for example,
iAd_Demo_AppViewController.m
.2. Lets' assume that an ad is always going to fail and move the banner out of view as soon as the app comes into view. We'll then wait for the successful message from the iAd Network and bring it into view. Add this following code around line 30:
- (void)viewWillAppear:(BOOL)animated { CGRect frame = self.view.bounds; CGPoint bannerOrigin =CGPointMake(CGRectGetMinX(frame), CGRectGetMaxY(frame)); bannerView.frame = CGRectMake(bannerView.bounds.origin.x, bannerOrigin.y, bannerView.frame.size.width, bannerView.frame.size.height); }
3. This takes the frame of the banner and sets the
y
value to be the height of the current view, which repositions it off screen...