无法看到iAds的横幅广告

时间:2015-08-12 09:15:41

标签: xcode swift iad

This is the screen right before the game如果他们无法看到iAds横幅,那么其他任何人都有问题但是当您第一次运行该应用时,会出现一个蓝色的大屏幕,并表示您现在已连接到iAds。我在我的iPhone上运行我的应用程序,我的iAD开发者应用程序测试填充率设置为100%

代码:

   import UIKit
    import StoreKit
    import SpriteKit
     import GameKit
      import iAd


     extension SKNode {
class func unarchiveFromFile(file : String) -> SKNode? {
    if let path = NSBundle.mainBundle().pathForResource(file, ofType: "sks") {
        var sceneData = NSData(contentsOfFile: path, options:   .DataReadingMappedIfSafe, error: nil)!
        var archiver = NSKeyedUnarchiver(forReadingWithData: sceneData)

        archiver.setClass(self.classForKeyedUnarchiver(), forClassName: "SKScene")
        let scene = archiver.decodeObjectForKey(NSKeyedArchiveRootObjectKey) as! GameScene
        archiver.finishDecoding()
        return scene
    } else {
        return nil
    }
}

  }

  class GameViewController: UIViewController, ADInterstitialAdDelegate      {
var interstitialAd:ADInterstitialAd!
var interstitialAdView: UIView = UIView()


override func viewDidLoad() {
    super.viewDidLoad()

    loadInterstitialAd()
    ADBannerView()


    func gameCenterViewControllerDidFinish(gameCenterViewController: GKGameCenterViewController!)
    {
        gameCenterViewController.dismissViewControllerAnimated(true, completion: nil)
    }




    var localPlayer = GKLocalPlayer()

    localPlayer.authenticateHandler = {(viewController, error) -> Void in

        if (viewController != nil) {
            let vc: UIViewController = self.view!.window!.rootViewController!
            vc.presentViewController(viewController, animated: true, completion: nil)
        }

        else {
            println((GKLocalPlayer.localPlayer().authenticated))

        }
    }








    if let scene = GameScene.unarchiveFromFile("GameScene") as? GameScene {
        // Configure the view.
        let skView = self.view as! SKView
        skView.showsFPS = false
        skView.showsNodeCount = false

        /* Sprite Kit applies additional optimizations to improve rendering performance */
        skView.ignoresSiblingOrder = true

        /* Set the scale mode to scale to fit the window */
        scene.scaleMode = .AspectFill

        skView.presentScene(scene)
    }



}



override func shouldAutorotate() -> Bool {
    return true
}

override func supportedInterfaceOrientations() -> Int {
    if UIDevice.currentDevice().userInterfaceIdiom == .Phone {
        return Int(UIInterfaceOrientationMask.AllButUpsideDown.rawValue)
    } else {
        return Int(UIInterfaceOrientationMask.All.rawValue)
    }
}

override func didReceiveMemoryWarning() {
    super.didReceiveMemoryWarning()
    // Release any cached data, images, etc that aren't in use.
}

override func prefersStatusBarHidden() -> Bool {
    return true
}


  func loadInterstitialAd() {
interstitialAd = ADInterstitialAd()
interstitialAd.delegate = self
  }

  func interstitialAdWillLoad(interstitialAd: ADInterstitialAd!) {

  }

  func interstitialAdDidLoad(interstitialAd: ADInterstitialAd!) {
interstitialAdView = UIView()
interstitialAdView.frame = self.view.bounds
view.addSubview(interstitialAdView)

interstitialAd.presentInView(interstitialAdView)
UIViewController.prepareInterstitialAds()
 }

func interstitialAdActionDidFinish(interstitialAd: ADInterstitialAd!) {
interstitialAdView.removeFromSuperview()
 }

  func interstitialAdActionShouldBegin(interstitialAd: ADInterstitialAd!, willLeaveApplication willLeave: Bool) -> Bool {
return true
  }

  func interstitialAd(interstitialAd: ADInterstitialAd!, didFailWithError error: NSError!) {

  }

  func interstitialAdDidUnload(interstitialAd: ADInterstitialAd!) {
interstitialAdView.removeFromSuperview()
   }

   }

0 个答案:

没有答案