Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS/Swift: more than 10 instances of ADBannerView

I am getting this warning after 10 screenviews.

More than 10 instances of ADBannerView or ADInterstitialView currently exist. This is a misuse of the iAd API, and ad performance will suffer as a result. This message is printed only once.

I have implemented AdBannerView through InterfaceBuilder. I am not explicitely creating an ADBannerView programmatically each time the view is loaded.

I am just referencing the AdBannerView as an @IBOutlet:

@IBOutlet weak var iAdsBanner: ADBannerView!

and hiding/showing it by changing its position, as suggested by Apple documentation.

Why am I getting this kind of error?

like image 682
Daniele B Avatar asked Dec 10 '15 14:12

Daniele B


1 Answers

Why are your making an outlet for bannerView. After iOS 7 things have been changed. If you want iAds then all you need to do is add the iAdsFramework, import the framework in your UIViewController and in your viewDidLoad() write the following code

 self.canDisplayBannerAds = true;

It will start displaying ads.

UPDATE Forget the canDisplayBannerAds thing as your requirement is different. Just create a single instance for banner View in your AppDelegate and in your view controller get that instance , set frames and add it as subview and don't forget to remove it when your controller disappears.check this link you will get the idea. stackoverflow.com/questions/28514758/…

like image 62
Muneeba Avatar answered Nov 01 '22 21:11

Muneeba