简体   繁体   English

iOS / Swift:超过10个ADBannerView实例

[英]iOS/Swift: more than 10 instances of ADBannerView

I am getting this warning after 10 screenviews. 我在10次屏幕浏览后收到此警告。

More than 10 instances of ADBannerView or ADInterstitialView currently exist. 目前存在超过10个ADBannerView或ADInterstitialView实例。 This is a misuse of the iAd API, and ad performance will suffer as a result. 这是对iAd API的误用,因此广告效果会受到影响。 This message is printed only once. 此消息仅打印一次。

I have implemented AdBannerView through InterfaceBuilder. 我已经通过InterfaceBuilder实现了AdBannerView I am not explicitely creating an ADBannerView programmatically each time the view is loaded. 每次加载视图时,我都没有明确地以编程方式创建ADBannerView。

I am just referencing the AdBannerView as an @IBOutlet: 我只是将AdBannerView引用为@IBOutlet:

@IBOutlet weak var iAdsBanner: ADBannerView!

and hiding/showing it by changing its position, as suggested by Apple documentation. 如Apple文档所示,通过更改其位置来隐藏/显示它。

Why am I getting this kind of error? 为什么我会遇到这种错误?

Why are your making an outlet for bannerView. 你为什么要为bannerView做出一个出路。 After iOS 7 things have been changed. 在iOS 7之后,事情发生了变化。 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 如果你想要iAds那么你需要做的就是添加iAdsFramework ,在你的UIViewController导入框架并在你的viewDidLoad()写下面的代码

 self.canDisplayBannerAds = true;

It will start displaying ads. 它将开始展示广告。

UPDATE Forget the canDisplayBannerAds thing as your requirement is different. 更新忘记canDisplayBannerAds事情,因为您的要求是不同的。 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. 只需在AppDelegate为横幅视图创建一个实例,然后在视图控制器中获取该实例,设置框架并将其添加为子视图,并且在控制器消失时不要忘记将其删除。检查此链接即可获得该想法。 stackoverflow.com/questions/28514758/… stackoverflow.com/questions/28514758/...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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