5

I am getting this warning when I switch views (which are just different themes) in my app. Any ideas, suggestions on why the app is not loading?

2011-04-25 16:14:20.211 MyApp [4121:40b] ADBannerView: WARNING A banner view (0x631bb30) has an ad but may be obscured. This message is only printed once per banner view.

enter image description here

It appears that when the view switches, the other view is just in the background, any ideas on how to do this.

** Note there is an excellent example on Apple's developer site, called iADSuite

Vikings
  • 2,527
  • 32
  • 45
  • can you help me on this http://stackoverflow.com/questions/5953418/implementation-for-iad – ajay May 11 '11 at 07:02

3 Answers3

11

This message means that a banner has a part that is or it is fully not visible. If you do read the iAd documentation from Apple you will notice that they recommend having only one iAd instance which you should use for all your views (uiviewcontrollers)

how I do iAds in my apps is - I have 1 singleton class which shows the iAd banner (thus I follow Apple's recommendation to have only 1 iAd instance). In all my viewcontrollers in the viewDidLoad method I show the iAd view from my singleton class and in viewWillDisappear I remove the iAd view from the viewcontroller.

This way the banner view is always visible in only 1 viewcontroller - therefore it never is "obscured" and such.

I hope this explanation helps you out :)

Marin Todorov
  • 6,377
  • 9
  • 45
  • 73
  • Okay, how do you remove an iAd from a view controller – Vikings Apr 25 '11 at 21:02
  • in my singleton class I have a property which is the iAd banner view. on viewDidLoad I do [self.view addSubview:singleton.iAd] so it adds to the uiviewcontroller's view hierarchy, and on viewWillDisappear [signleton.iAd removeFromSuperview] ... it's very easy – Marin Todorov Apr 25 '11 at 21:06
  • 1
    basically you call removeFromSuperview on the iAd banner view, this is how you remove it – Marin Todorov Apr 25 '11 at 21:07
  • How do you deal with the delegate, if you set it to nil in viewWillDissapear, it will cause problem when a user opens an ad. – Jonathan. Feb 07 '12 at 22:42
  • @Jonathan - never had any troubles with it, I'm not sure what problem do you refer to – Marin Todorov Feb 08 '12 at 00:17
  • in viewWillDissapear do you do `banner.delegate = nil`? – Jonathan. Feb 08 '12 at 00:19
  • no, I have 1 Singleton class which is my banner controller and it also keeps the banner view itself, so the class is self sufficient to handle iAd. the different view controllers in the app then just "register" with this one controller when they are shown on the screen as to be the active view controller to own the banner view – Marin Todorov Feb 08 '12 at 00:24
  • Probably a slightly different use case, but I have UITabBarController and when switching between the tabs, the viewWillAppear event is only called the first time they are shown and not subsequent times. However viewDidAppear is called - so I moved the re-register to that method. – Chris Kimpton Feb 12 '12 at 15:01
0

Look at your view heirarchy. Do you have the new view set with an iAd and is that overlaying your iAd view. Or are you recreating the iAd view again? Dump the view heirarchy and see what views are present, you may find you have two instances.

Try: [topView recursiveDescription]

David Neiss
  • 8,161
  • 2
  • 20
  • 21
0

I know this is not the answer to your question for your scenario, but for others it may be, as it was for me. I am using Adwhirl and was using the animated transitions. I turned those transitions off and diminished these warnings drastically.

Joshua Goossen
  • 1,714
  • 1
  • 17
  • 36