1

I successfully added an iAd banner to my game (which plays in landscape mode), however I'm lost as to how to handle the ad being pushed. When the banner ad is pushed the game continues in the background and the player dies. Is there code to pause the game when the banner ad is clicked and resume when the ad goes away? Also when the banner ad is clicked, the ad shows up in portrait mode. Can I keep the ad in landscape mode so it is in sync with my landscape game? I'm a newbie please bear with me thanks!

rmaddy
  • 314,917
  • 42
  • 532
  • 579
JakeFromStateFarm
  • 547
  • 1
  • 4
  • 8

1 Answers1

1

You need to become the banner's delegate.

In your header file, change the @interface line by adding <ADBannerViewDelegate>, or add , ADBannerViewDelegate inside the angle brackets if you already have some. In the code where you create your banner ad, add a line like this:

self.bannerAdView.delegate = self;

Or if you're using Storyboards or IB, connect the banner ad's delegate outlet to your controller.

Once that's all done, implement these methods:

- (BOOL)bannerViewActionShouldBegin:(ADBannerView *)banner willLeaveApplication:(BOOL)willLeave
{
    if (!willLeave)
    {
        // pause your game here
    }

    return YES;
}

- (void)bannerViewActionDidFinish:(ADBannerView *)banner
{
    // unpause your game
}

If your entire game is landscape, I'd recommend that you set your app to only support landscape orientations. This is done in your target settings as described in this technical note. I think that this will restrict the ads to landscape, but I've only tested that on an iPad, so it may be different on the iPhone.

Simon
  • 25,468
  • 44
  • 152
  • 266
  • how would I create a pause and resume logic? right now my game has no pause or resume button/logic? @Simon – JakeFromStateFarm Mar 11 '14 at 18:23
  • Without knowing how your game is implemented, I don't have enough information to say. It would really be another SO question. – Simon Mar 11 '14 at 18:26
  • My game is running on a NSTimer scheduledTimerWithTimeInterval.., I was thinking if it would be possible to invalidate the timer with a button and also for the iAd? @Simon – JakeFromStateFarm Mar 11 '14 at 18:46