[英]Adding AdBannerView into SpriteKit
我目前正在使用SpriteKit,並且正在嘗試將iAd納入其中。 從我所看到的,似乎最好的方法是將其放在UIViewController的子類中,因為您無法將AdBannerView添加到Sk Scene。 但是,我不知道如何將UIViewContoller類添加到我的SKScene中。
我的UIViewController的Ads類包含:
iAdSupported = iAdTimeZoneSupported()
bannerDisplayed = false
if iAdSupported {
iAdView = ADBannerView(adType: ADAdType.Banner)
iAdView?.frame = CGRectMake(0, 0 - iAdView!.frame.height, iAdView!.frame.width, iAdView!.frame.height)
iAdView?.delegate = self
self.view.addSubview(iAdView!)
}
該類將像添加到視圖中一樣進行調試,但是在SKScene頂部不可見。 致電廣告類:
var AdsController: Ads!
AdsController = Ads()
AdsController.setupAds()
我還在SKScene中嘗試了以下方法:
var currentViewController:UIViewController=UIApplication.sharedApplication().keyWindow.rootViewController!
currentViewController.presentViewController(Ads, animated: true, completion: nil)`
我看了很多頁面,似乎無法迅速找到解決該問題的任何方法。
任何幫助將是巨大的,非常感謝!
缺口
嘗試使用此類類https://github.com/sunkanmi-akintoye/iOS-Ads-Admob-and-iAd確實很容易實現。 在ViewController中添加以下行:
override func viewDidLoad() {
super.viewDidLoad()
Ads.sharedInstance.presentingViewController = self
...
}
這是為了展示AdBannerView:
Ads.sharedInstance.showInterAd()
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.