我在我的所有viewcontroller页面上都有这段代码来控制跨多个页面的AdBanner。它在我的应用程序的最后一个版本上正确工作,但是由于某些原因,我认为我的应用程序没有调用bannerViewDidLoadAd或didFailToReceiveAdWithError函数。而且,当我经常更改页面时,我会得到这个错误。`
警告:目前存在10多个ADBannerView或ADInterstitialView实例。这是对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发布于 2016-01-28 07:30:18
尝试更改以下代码:
override func viewWillDisappear(animated: Bool) {
UIiAd.delegate = nil
UIiAd.removeFromSuperview()
}至:
override func viewWillDisappear(animated: Bool) {
UIiAd.removeFromSuperview()
UIiAd.delegate = nil
}https://stackoverflow.com/questions/34652753
复制相似问题