在我的gameviewcontroller中,我可以像这样展示插页式广告:
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不在那里工作,解决方案是什么?
答案 0 :(得分:1)
这是斯威夫特的答案:
let currentViewController:UIViewController=UIApplication.sharedApplication().keyWindow!.rootViewController!
interstitial.presentFromRootViewController(currentViewController)