user1483652
user1483652

Reputation: 799

How to share a iAd adbanner across view's?

I am making a iPhone app, I am currently using iAd's in my view's. I've read something about apple recommending to share the adbanner's through out the view's. How can i do this because I have read the apple documentation and it was not clear enough and i was confused, please help me, if their are any tutorials please tell me or just answer and point me in the right way. Currently I have a ad for every view controller and it runs nice but it comes with a error: Too many active banners (10). Creation of new banners will be throttled. Please help, i am using storyboards and the latest Xcode :) thanks

Upvotes: 3

Views: 789

Answers (2)

Darren
Darren

Reputation: 10398

The way I do it is use a Singleton class that creates the adView, this way you only ever get 1 adView. Then in your viewDidAppear methods of all your ViewControllers you simply add the adView to your view.

You can see my code in the accepted answer here although that is for an AdWhirl ad view, it shouldn't be too difficult to change it for an iAd ad view.

Upvotes: 2

CodaFi
CodaFi

Reputation: 43330

This is the perfect case for a singleton. Many have simply made a subclass of ADBannerView, which can then be added to your view in -viewDidLoad (or -viewDidAppear with the proper precautions taken) and removed in -viewDidDisappear for each View Controller.

Upvotes: 0

Related Questions