iOS/Swift: 超过10个ADBannerView实例

iOS/Swift: more than 10 instances of ADBannerView

我在 10 次屏幕浏览后收到此警告。

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.

我已经通过 InterfaceBuilder 实现了 AdBannerView。我 不是 每次加载视图时都以编程方式明确创建 ADBannerView。

我只是将 AdBannerView 引用为 @IBOutlet:

@IBOutlet weak var iAdsBanner: ADBannerView!

和 hiding/showing 按照 Apple 文档的建议改变它的位置。

为什么会出现这种错误?

你为什么要为 bannerView 做一个出口。在 iOS 之后,有 7 件事发生了变化。如果您想要 iAds,那么您需要做的就是添加 iAdsFramework,在 UIViewController 中导入框架,然后在 viewDidLoad() 中编写以下代码

 self.canDisplayBannerAds = true;

它将开始展示广告。

更新 忘记 canDisplayBannerAds 的东西,因为你的要求是不同的。只需在您的 AppDelegate 中为横幅视图创建一个实例,然后在您的视图控制器中获取该实例,设置框架并将其添加为子视图,并且不要忘记在您的控制器 disappears.check this link 你会明白的。