dimanche 30 novembre 2014

How to create a iAd banner?

I'm still a noob developper and I just finished my little game and now I want to integrate AdBanner.


With the code bellow the banner doesn't appear on the screen.


Someone can help me ?


Here my GameViewController code :



import UIKit
import SpriteKit
import AVFoundation
import iAd

var defaults = NSUserDefaults()
var highscore = defaults.integerForKey("highscore")


class GameViewController: UIViewController, ADBannerViewDelegate {

var bannerView:ADBannerView?


override func viewDidLoad() {
super.viewDidLoad()

self.canDisplayBannerAds = true
self.bannerView?.delegate = self
self.bannerView?.hidden = true

var skView = self.originalContentView as SKView
var scene:SKScene = GameScene(size: skView.bounds.size)

skView.showsFPS = false
skView.showsNodeCount = false
skView.showsPhysics = false

let turbulence = SKFieldNode.turbulenceFieldWithSmoothness(0.1, animationSpeed: 0.1)
scene.addChild(turbulence)
let noise = SKFieldNode.turbulenceFieldWithSmoothness(0.4, animationSpeed: 0.1)
scene.addChild(noise)

skView.presentScene(scene)

}

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

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

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

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

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


screenshot




Aucun commentaire:

Enregistrer un commentaire