问题
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)
and here's my error:
cannot convert value of type 'GameScene' to expected argument type 'UIViewController!'
Hope one of you has the answer! thx
回答1:
You're trying to present interstitial
from itself.
You should present it from a ViewController which is currently visible:
self.interstitial.presentFromRootViewController(self)
(supposed that self
is a View Controller).
Update:
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.
}
来源:https://stackoverflow.com/questions/34692755/swift-cannot-convert-value-of-type-gamescene-to-expected-argument-type-uivie