gpt4 book ai didi

swift - ADBannerView 问题

转载 作者:行者123 更新时间:2023-11-30 13:48:12 25 4
gpt4 key购买 nike

我的所有 viewcontroller 页面上都有此代码,用于跨多个页面控制我的 AdBanner。它在我的应用程序的最新版本上正常工作,但由于某种原因,在此更新中我正在处理我认为我的应用程序没有调用 bannerViewDidLoadAddidFailToReceiveAdWithError功能。当我频繁更改页面时,我也会收到此错误。 `

"WARNING: 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."

`我有什么遗漏的吗?谢谢

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

关于swift - ADBannerView 问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34652753/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com