IAd Banner Ads Jerking The Screen

140 views Asked by At

I have released my game to the App Store and iAd banner ads are enabled at the bottom of the screen. I have used self.CanDisplayBannerAds = true to enable the ads. The ads work fine and there's no problem with the ads loading or going away. The problem is that whenever the ads appear, the screen jerks. This jerk disables touches for just a split second. This split second can be enough for the player to lose the game. It is very annoying and definitely a problem that needs fixed. Has anyone else had this problem? Is there anything I could do to fix it?

If you would like to see the problem for yourself, you can download the app, it's free: https://appsto.re/us/FB4u5.i

1

There are 1 answers

0
Garrett O'Grady On

I was having that same problem and this fixed it for me.

import UIKit
import SpriteKit
import iAd
import GameKit


let adBannerView = ADBannerView(frame: CGRect.zeroRect)

class GameViewController: UIViewController, ADBannerViewDelegate  {
  var bannerView:ADBannerView?
  override func viewDidLoad() {
    super.viewDidLoad()

    if let scene = GameScene.unarchiveFromFile("GameScene") as? GameScene {
        let skView = self.view as SKView
        loadAds()
  }
 }


 func loadAds() {

    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)

}

func bannerViewWillLoadAd(banner: ADBannerView!) {

}

func bannerViewDidLoadAd(banner: ADBannerView!) {
    adBannerView.hidden = false
}

func bannerViewActionDidFinish(banner: ADBannerView!) {

}

func bannerViewActionShouldBegin(banner: ADBannerView!, willLeaveApplication willLeave: Bool) -> Bool {
    return true
}

func bannerView(banner: ADBannerView!, didFailToReceiveAdWithError error: NSError!) {
    adBannerView.hidden = true
}