我有一个sprite-kit游戏,第一个广告加载到gameOver
,但是之后的gameOver
后面会出现以下错误:
<Google> No UIViewController supplied to the ad. Cannot continue.
这是我的代码的外观:
initWithSize:
-(id)initWithSize:(CGSize)size {
if (...]) {
...
self.interstitial = [[GADInterstitial alloc] init];
self.interstitial.adUnitID = @"ca-app-pub-9147160832662960/2548046734";
GADRequest *request = [GADRequest request];
// Requests test ads on simulators.
[self.interstitial loadRequest:request];
...
}
return self;
}
GAMEOVER:
-(void)gameOver
{
self.isGameOver = YES;
...
if ([self.interstitial isReady]) {
self.interstitial.delegate = self;
[self.interstitial presentFromRootViewController:_viewController];
}
...
}
答案 0 :(得分:0)
scene.viewController = self.viewController;
这是我的GameScene中需要添加到initWithSize的内容。 现在完美运作