我试图制作iAd横幅广告。控制台说横幅已成功加载和获取,但我无法在模拟器中看到它。我在这做错了什么?
class GameViewController: UIViewController, ADBannerViewDelegate {
var banner : ADBannerView = ADBannerView()
在viewDidLoad中:
{
banner.delegate = self
banner.alpha = 0.0
NSNotificationCenter.defaultCenter().addObserver(self, selector: "bannerViewDidLoadAd", name: "banner", object: nil)
}
func bannerViewWillLoadAd(banner: ADBannerView!) {
println("banner tries to load")
}
func bannerViewDidLoadAd(banner: ADBannerView!) {
println("banner successfully fetched")
UIView.animateWithDuration(0.5, animations: {banner.alpha = 1.0})
UIView.commitAnimations()
}
func bannerViewActionShouldBegin(banner: ADBannerView!, willLeaveApplication willLeave: Bool) -> Bool {
return true
}
func bannerViewActionDidFinish(banner: ADBannerView!) {
println("banner is closed")
}
func bannerView(banner: ADBannerView!, didFailToReceiveAdWithError error: NSError!) {
println("banner failed too! Man...")
println(error.localizedDescription)
UIView.animateWithDuration(0.5, animations: {banner.alpha = 1.0})
}
在GameScene中:
func iBanner() {
NSNotificationCenter.defaultCenter().postNotificationName("banner", object: nil)
}
override func didMoveToView(view: SKView) {
iBanner()
}