I have this code on all my viewcontroller
pages to control my AdBanner
across multiple pages. It works correctly on the last version on my app but for some reason in this update I'm working on I don't think my app is calling either the bannerViewDidLoadAd
or didFailToReceiveAdWithError
functions. Also I am getting this error when I change pages a lot. `
"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."
` Is there something I am missing? Thanks
// 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