【问题标题】:No UIViewController supplied to the ad. Cannot continue没有向广告提供 UIViewController。无法继续
【发布时间】:2015-03-22 22:04:50
【问题描述】:

我有一个 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];
    }
   ...
}

【问题讨论】:

  • 所以你需要弄清楚第一场比赛和随后的比赛之间有什么变化。上面的代码无法查明您的问题。
  • 感谢您的回复@sangony,我已经为此花费了数小时,但无法找到问题的根源。上面的代码发生在我的 GameScene.m 中,而不是在我的 ViewController.m 中。我的代码中没有其他地方 _viewController 被更改,所以我不确定为什么在加载第一个广告后它不再加载任何广告

标签: ios sprite-kit admob interstitial


【解决方案1】:
scene.viewController = self.viewController;

这是需要添加到我的 GameScene 中的 initWithSize 的内容。 现在完美运行

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-08-02
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多