我的iAd代码有什么问题吗?

时间:2016-06-29 17:30:32

标签: ios swift sprite-kit iad ads

我的应用程序仅在几天前获得批准,并在屏幕底部显示了iAd横幅。我知道广告可能需要一周的时间才会开始出现,但是我正在等待..有人可以确保我的代码中没有任何错误吗?

import UIKit
import SpriteKit
import iAd
import GameKit

class GameViewController: UIViewController, ADBannerViewDelegate, GKLocalPlayerListener {

var adBanner: ADBannerView!
override func viewDidLoad() {
    super.viewDidLoad()
    authenticateLocalPlayer()
    if let scene = GameScene(fileNamed:"GameScene") {
        // Configure the view.
        let skView = self.view as! SKView

        skView.ignoresSiblingOrder = true
        scene.scaleMode = .AspectFill

        skView.presentScene(scene)


    }

}

func loadBanner() {

    adBanner = ADBannerView(frame: CGRect.zero)
    adBanner.center = CGPoint(x: adBanner.center.x, y: view.bounds.size.height - adBanner.frame.size.height / 2)
    adBanner.delegate = self
    adBanner.hidden = true
    view.addSubview(adBanner)
}
func bannerViewDidLoadAd(banner: ADBannerView!) {
    adBanner.hidden = false
}
func bannerView(banner: ADBannerView!, didFailToReceiveAdWithError error: NSError!) {

    adBanner.hidden = true
}
func bannerViewActionShouldBegin(banner: ADBannerView!, willLeaveApplication willLeave: Bool) -> Bool {
    return true
}
override func shouldAutorotate() -> Bool {
    return true
}

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

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

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


func authenticateLocalPlayer() {
    let localPlayer = GKLocalPlayer.localPlayer()
    localPlayer.authenticateHandler = {(viewController, error) -> Void in

        if (viewController != nil) {
            self.presentViewController(viewController!, animated: true, completion: nil)
        }
        else {
            print((GKLocalPlayer.localPlayer().authenticated))
        }
    }
}

}

现在它只显示一个白色矩形。我的代码有什么问题,或者我只是需要等待我的应用开始接收广告吗?

2 个答案:

答案 0 :(得分:5)

iAd自明天(2016年6月30日)起正式停用。我现在不确定“注册”过程,但我相信Apple几个月前停止注册应用以接收来自其网络的广告

答案 1 :(得分:0)

谁致电loadBanner()

您可以考虑覆盖viewDidAppear()并将代码转移到那里。