1

I'd like to occasionally hide an ADBannerView. I'm thinking about banner.hidden = YES and similar to un-hide. I'm concerned that Apple will frown upon this because receiving and "displaying" ads while the banner is hidden seems questionable.

In bannerView:didFailToReceiveAdWithError: I'm animating the banner off the screen bottom. I'm open to doing this instead of using the hidden property if it's somehow better.

Perhaps it's possible to tell the banner to stop requesting ads. Unfortunately nothing jumped out at me while looking over ADBannerView.h.

What's the best way to programatically hide ADBannerView?

SundayMonday
  • 19,147
  • 29
  • 100
  • 154
  • 2
    Why not just remove/dealloc the view when it's no longer needed? – titaniumdecoy Jun 25 '12 at 21:29
  • 1
    Good suggestion. I tried this and the banner seemed to have trouble receiving ads if it was removed and re-added a few times in 1-2 minutes. – SundayMonday Jun 25 '12 at 22:38
  • 1
    I keep the ad hidden with banner.hidden = YES until I successfully receive an ad. – Scott Bossak Jun 25 '12 at 22:44
  • @ScottBossak any way to prevent adbanners from receiving ads? – SundayMonday Jun 25 '12 at 23:01
  • 1
    You might be able to set the AdBannerView delegate to nil. I haven't tried that though. – Scott Bossak Jun 26 '12 at 14:03
  • I think banner.hidden = YES should be ok - this is an Apple matter to track if your banner is visible for user now or not (we don't speak now about misuse cases e.g. when you can intentionally put other control above the banner - this is obvious missuse). Similar case: what if you have view controller with banner and this controller is not currently visible for user? - it would be terrible if you should track all banners and carry about stopping obtaining ads info if banner is not visible for the moment – sergtk Nov 16 '12 at 12:32

1 Answers1

7

The way to tell a banner view to stop receiving ads is to destroy it when not needed, as stated in the iAd Programming Guide [with bold emphasis added by me]:

When designing your application, keep the following principles in mind:

  • Only create a banner view when you intend to display it to the user. Otherwise, it may cycle through ads and deplete the list of available advertising for your application.
  • If the user navigates from a screen of content with a banner view to a screen that does not have a banner view, and you expect them to be on that screen for a long period of time, remove the banner view from the view hierarchy, set its delegate to nil and release it before transitioning to the new screen of content. More generally, avoid keeping a banner view around when it is invisible to the user.
Community
  • 1
  • 1
Squawky
  • 304
  • 2
  • 7