我一直在尝试在我的项目中为一个视图实现一个插页式广告,但我总是得到同样的错误:“当我在下面定义调用时,无法将'Start'类型的值转换为预期的参数类型'UIViewController'”
有人知道如何在SprtieKit中实现它们,因为我只找到了Swift资源吗?
这是我的代码:
import SpriteKit
import GameKit
import GoogleMobileAds
class Start: SKScene, GADInterstitialDelegate{
var interstitial: GADInterstitial!
override func didMove(to view: SKView) {
interstitial = createAndLoadInterstitial()
interstitial.delegate = self
if self.interstitial.isReady {
NotificationCenter.default.addObserver(self, selector: Selector(("quitToLevel:")), name: NSNotification.Name(rawValue: "quitToLevelID"), object: nil)
interstitial.present(fromRootViewController: self) //->Error: Cannot convert value of type 'Start' to expected argument type 'UIViewController'
}else{
print("add didn´t load")
}
}
func createAndLoadInterstitial() -> GADInterstitial {
let interstitial = GADInterstitial(adUnitID: "ca-app-pub-3940256099942544/4411468910")
interstitial.delegate = self
interstitial.load(GADRequest())
return interstitial
}
func interstitialDidDismissScreen(_ ad: GADInterstitial) {
interstitial = createAndLoadInterstitial()
}
}