繁体   English   中英

将AdBannerView添加到SpriteKit

[英]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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM