简体   繁体   中英

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?

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/…

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM