This is the code I am using:
var bannerView = ADBannerView()
self.canDisplayBannerAds = true
//show ad banner if an ad loads
func bannerViewDidLoadAd(banner: ADBannerView!)
{bannerView.hidden = false}
//hide ad banner if the ad fails to load
func bannerViewFailsToLoadAd(banner: ADBannerView!,didFailToReceiveAdWithError error: NSError!)
{bannerView.hidden = true
println("failed to receive ad")}
When I set the iAd fill rate to 0% nothing is printed and I get this output from the console:
ADBannerView: Unhandled error (no delegate or delegate does not implement didFailToReceiveAdWithError:): Error Domain=ADErrorDomain Code=5 "The operation couldn’t be completed. Banner view is visible but does not have content" UserInfo=0x7fd3fd3335e0 {ADInternalErrorCode=5, NSLocalizedFailureReason=Banner view is visible but does not have content, ADInternalErrorDomain=ADErrorDomain}
Delegate methods will not be called when using
self.canDisplayBannerAds = true. You need to create anADBannerViewyourself and set itsdelegatefor the delegate methods to be called, for example,bannerView.delegate = self.self.canDisplayBannerAds = trueis a no hassle way of implementing iAd banners. It will create anADBannerViewfor you, display it if it receives an ad, and hide it if it does not receive an ad. There is no need to implement delegate methods when implementing your iAd banner in this way.So you have two options, remove
var bannerView = ADBannerView()and use the iAd banner thatself.canDisplayBannerAds = trueprovides, or removeself.canDisplayBannerAds = trueand finish implementing your ownADBannerView.If you decide to implement your own
ADBannerViewcheck my answer here, just ignore the AdMob implementation.