【问题标题】:App freeze after iAd/google interstitial popupiAd/google 插页式弹出窗口后应用程序冻结
【发布时间】:2014-10-25 11:13:23
【问题描述】:

我在 cocos2d(版本 3.1.0)中遇到了一个非常奇怪的插页式广告问题。这是我用来加载两个插页式广告的代码。

- (void)interstitialDidReceiveAd:(GADInterstitial *)interstitial {
    [interstitial presentFromRootViewController:[CCDirector sharedDirector]];
    interstitial.delegate = nil;
    interstitial = nil;
}
- (void)interstitialAdDidLoad:(ADInterstitialAd *)interstitialAd {
    [interstitialAd presentFromViewController:[CCDirector sharedDirector]];

}

一切似乎都很好,工作正常,直到您在插页式广告弹出之前将手指放在显示屏上,然后当您取消触摸(松开手指)并关闭弹出窗口时,应用程序变得无响应,触摸处理程序会根本不起作用,您必须重新启动应用程序。我挣扎了几个小时,但没有成功找到问题的原因。会不会是 CCDirector 停止和启动动画方法?

【问题讨论】:

    标签: ios cocos2d-iphone iad interstitial


    【解决方案1】:

    我找到了解决该错误的方法。我所做的是在显示 google/iAD 插页式广告之前禁用响应管理器,您可以查看以下方法。

    - (void)interstitialDidReceiveAd:(GADInterstitial *)interstitial {
        [[[CCDirector sharedDirector]responderManager]setEnabled:false];
        [interstitial presentFromRootViewController:[CCDirector sharedDirector]];
        interstitial.delegate = nil;
        interstitial = nil;
    }
    - (void)interstitialAdDidLoad:(ADInterstitialAd *)interstitialAd {
        [[[CCDirector sharedDirector]responderManager]setEnabled:false];
        [interstitialAd presentFromViewController:[CCDirector sharedDirector]];
    }
    

    之后,我在 CCDirectorIOS.m 文件中的 - (void) startAnimation 中再次启用它,并输入以下代码。

    if (![[self responderManager]isEnabled]) {
            [[self responderManager]setEnabled:true];
    }
    

    我知道这不是一个优雅的解决方案,因为直接更改库代码并不总是一个好主意,但我找不到任何其他替代方案。我认为这是一个 cocos2d 错误,但我不确定,可能有经验的人可以指出确切的问题。我不知道这个错误是否存在于最新的 cocos2d 版本中。

    编辑:此行为也存在于最新版本中。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-03-24
      • 2012-03-08
      • 1970-01-01
      • 2019-05-25
      • 1970-01-01
      相关资源
      最近更新 更多