【问题标题】:Showing AdMob interstitial in GameScene(SKScene)在 GameScene (SKScene) 中显示 AdMob 插页式广告
【发布时间】:2015-01-23 17:05:30
【问题描述】:

在我的游戏视图控制器中,我可以像这样展示插页式广告:

    var request = GADRequest()
    request.testDevices = [GAD_SIMULATOR_ID];
    var interstit = GADInterstitial()
    interstit = interstit2
    interstit.adUnitID = "ca-app-pub-3940256099942544/2934735716"
    interstit.loadRequest(request)
    println("req loaded admob")

if interstit.isReady{
       interstit.presentFromRootViewController(self)
       request()
    }

但我想在 GameScene(SKScene) 中调用相同的插页式广告,而 presentfromrootviewcontroller 在那里不起作用,解决方案是什么?

【问题讨论】:

标签: swift uiviewcontroller admob skscene


【解决方案1】:

这就是 Swift 中的答案:

let currentViewController:UIViewController=UIApplication.sharedApplication().keyWindow!.rootViewController!

interstitial.presentFromRootViewController(currentViewController)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-01-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-04-11
    相关资源
    最近更新 更多