Here's how I did it; maybe not all of this is necessary.
I did not use the banner in the Storyboard, therefore IBOutlet is not needed.
In addition, if you manually create a banner, you do not need to set self.canDisplayBannerAds
This feature (ported from ObjC) is a way to display ads.
func loadAds(){ adBannerView = ADBannerView(frame: CGRect.zeroRect) adBannerView.center = CGPoint(x: adBannerView.center.x, y: view.bounds.size.height - adBannerView.frame.size.height / 2) adBannerView.delegate = self adBannerView.hidden = true view.addSubview(adBannerView) }
This is called in viewDidLoad . Then in the delegate method didLoadAd I set adBannerView.hidden = false and in didFailToReceiveAdWithError , adBannerView.hidden = true
I think hidden better than alpha in this situation, as it seems more natural. I believe (but not sure) that when hidden, the view is not drawn at all by the GPU, but with alpha 0, it is still drawn, but made invisible (correct me if I am wrong).
This is my setup, and it worked for me, so hopefully this will work in your case too!
erdekhayser
source share