广告横幅查看问题



我在所有viewcontroller页面上都有这段代码,可以在多个页面上控制我的AdBanner。它在我的应用程序的上一个版本上运行正常,但由于某种原因,在我正在进行的这次更新中,我认为我的应用没有调用bannerViewDidLoadAddidFailToReceiveAdWithError函数。此外,当我频繁更改页面时,也会出现此错误

"警告:ADBannerView或ADInterstitialView的实例超过10个目前存在。这是对iAd API和广告性能的滥用将因此遭受损失。此消息只打印一次。"

`我有什么东西不见了吗?感谢

// Ad controller
var UIiAd: ADBannerView = ADBannerView()
var screenHeight = UIScreen.mainScreen().bounds.height
var adBannerHeight: CGFloat = 50
@IBOutlet var constOne: NSLayoutConstraint!
func appdelegate() -> AppDelegate {
    return UIApplication.sharedApplication().delegate as! AppDelegate
}
override func viewWillDisappear(animated: Bool) {
    UIiAd.delegate = nil
    UIiAd.removeFromSuperview()
}
func bannerViewDidLoadAd(banner: ADBannerView!) {
    UIView.beginAnimations(nil, context: nil)
    UIView.setAnimationDuration(1)
    UIiAd.alpha = 1
    adBannerHeight = 50
    UIView.commitAnimations()
    constOne.constant = 58
    print("ad loaded")
}
func bannerView(banner: ADBannerView!, didFailToReceiveAdWithError error: NSError!) {
    UIView.beginAnimations(nil, context: nil)
    UIView.setAnimationDuration(1)
    UIiAd.alpha = 0
    adBannerHeight = 0
    UIView.commitAnimations()
    constOne.constant = 8
    print("error")
}
override func viewWillAppear(animated: Bool) {
    UIiAd.delegate = self
    UIiAd = self.appdelegate().UIiAd
    UIiAd.frame = CGRectMake(0, screenHeight - adBannerHeight , 0, 0)
    self.view.addSubview(UIiAd)
}
// End of Ad Controller

尝试更改此代码:

override func viewWillDisappear(animated: Bool) {
    UIiAd.delegate = nil
    UIiAd.removeFromSuperview()
}

收件人:

override func viewWillDisappear(animated: Bool) {
     UIiAd.removeFromSuperview()
     UIiAd.delegate = nil
}

相关内容

  • 没有找到相关文章

最新更新