【发布时间】:2016-01-31 04:21:14
【问题描述】:
我正在使用精灵套件,我希望横幅广告显示在我的所有场景中。我不想使用 self.candisplaybannerads,因为它会将我的场景推到游戏中期并导致它在游戏中死亡。
以下是错误:警告:当前存在超过 10 个 ADBannerView 或 ADInterstitialView 实例。这是对 iAd API 的滥用,广告效果将因此受到影响。此消息仅打印一次。
这是我的代码:
import UIKit
import iAd
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate, ADBannerViewDelegate {
var window: UIWindow?
var AdBanner = ADBannerView()
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject : AnyObject]?) -> Bool {
// Override point for customization after application launch.
UIViewController.prepareInterstitialAds()
/* Ad Banner Settings */
AdBanner = ADBannerView()
AdBanner.frame = CGRectZero
AdBanner.delegate = self
AdBanner.backgroundColor = UIColor.clearColor()
/* All iAd Functions */
func bannerViewActionShouldBegin(banner: ADBannerView!, willLeaveApplication willLeave: Bool) -> Bool {
/* whatever you need */
return true
}
func bannerViewActionDidFinish(banner: ADBannerView!) {
/* whatever you need */
}
func bannerViewDidLoadAd(banner: ADBannerView!) {
AdBanner.hidden = false
}
func bannerView(banner: ADBannerView!, didFailToReceiveAdWithError error: NSError!) {
NSLog("Error Loading Ad")
/* whatever you need */
AdBanner.hidden = true
}
func bannerViewWillLoadAd(banner: ADBannerView!) {
/* whatever you need */
}
return true
}
这里是我所说的横幅广告
class GameViewController: UIViewController {
let appDelegate = UIApplication.sharedApplication().delegate as! AppDelegate
override func viewDidLoad() {
super.viewDidLoad()
appDelegate.AdBanner.frame = CGRectMake(0, self.view.frame.size.height-appDelegate.AdBanner.frame.size.height, appDelegate.AdBanner.frame.size.width, appDelegate.AdBanner.frame.size.height)
self.view .addSubview(appDelegate.AdBanner)
//authenticateLocalPlayer()
if let scene = StartScreen(fileNamed:"StartScreen") {
// 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)
}
}
【问题讨论】:
标签: swift sprite-kit iad