当我运行游戏时,一个白色的盒子出现在游戏的顶部,我猜广告应该出现在里面,但从来没有出现过广告!
我是做错了什么,遗漏了某段代码,还是瞎了眼?哈哈。
我对这个女孩什么都不熟悉!
这是它的图像
这是ViewController代码!

import UIKit
import SpriteKit
import iAd


class GameViewController: UIViewController, ADBannerViewDelegate{

@IBOutlet var Banner: ADBannerView!

override func viewDidLoad() {
    super.viewDidLoad()

    if let scene = GameScene.unarchiveFromFile("GameScene") as? GameScene {
        // Configure the view.
        let skView = self.view as SKView
        skView.ignoresSiblingOrder = true

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

        skView.presentScene(scene)

        loadAds()
    }
}

func loadAds() {
    self.canDisplayBannerAds = true
    Banner = ADBannerView(frame: CGRect.zeroRect)
    Banner.center = CGPointMake(Banner.center.x, view.bounds.size.height - Banner.frame.size.height / 2)
    Banner.delegate = self
    Banner.hidden = true
    view.addSubview(Banner)
}


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

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

func bannerViewWillLoadAd(banner: ADBannerView!) {

}

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

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

最佳答案

好像一下子就起作用了!收到错误信息,但它已经消失,广告实际上已经加载!:)
不知道发生了什么事!

关于ios - iAd未显示任何广告,Swift,ViewController,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/29785476/

10-14 01:51