Swift:无法将'GameScene'类型的值转换为预期的参数类型'UIViewController!' [英] Swift: cannot convert value of type 'GameScene' to expected argument type 'UIViewController!'
本文介绍了Swift:无法将'GameScene'类型的值转换为预期的参数类型'UIViewController!'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当用户迷路时,我正在尝试在我的应用程序中加载admob插页式广告,但是我不能这样做,因为我使用的是spritekit(swift),这是我的代码:
I am trying to load an admob interstitial ad in my app when the users lost but i can't because i am using spritekit (swift), here's my code:
self.interstitial.presentFromRootViewController(interstitial)
我的错误:
cannot convert value of type 'GameScene' to expected argument type 'UIViewController!'
希望你们中的一个有答案! thx
Hope one of you has the answer! thx
推荐答案
您要尝试展示自身的插页广告
。
您应该从当前可见的ViewController中显示它:
You should present it from a ViewController which is currently visible:
self.interstitial.presentFromRootViewController(self)
(假设 self
是一个View Controller)。
(supposed that self
is a View Controller).
更新:
如果您遵循Google 教程 专心,您会确切地看到我在说:
If you follow Google tutorial attentively, you will see there exactly what I'm talking about:
func gameOver() {
if self.interstitial.isReady {
self.interstitial.presentFromRootViewController(self)
}
// Rest of game over logic goes here.
}
这篇关于Swift:无法将'GameScene'类型的值转换为预期的参数类型'UIViewController!'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文