没有向广告提供 UIViewController。无法继续
No UIViewController supplied to the ad. Cannot continue
我有一个 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;
}
游戏结束:
-(void)gameOver
{
self.isGameOver = YES;
...
if ([self.interstitial isReady]) {
self.interstitial.delegate = self;
[self.interstitial presentFromRootViewController:_viewController];
}
...
}
scene.viewController = self.viewController;
这是需要添加到我的 GameScene 中的 initWithSize 的内容。
现在完美运行
我有一个 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;
}
游戏结束:
-(void)gameOver
{
self.isGameOver = YES;
...
if ([self.interstitial isReady]) {
self.interstitial.delegate = self;
[self.interstitial presentFromRootViewController:_viewController];
}
...
}
scene.viewController = self.viewController;
这是需要添加到我的 GameScene 中的 initWithSize 的内容。 现在完美运行