O'Reilly logo

iAd Production by Ben Collier

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Time for action — ban the banner

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, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required