【问题标题】:How to hide iAd in Cocos2D如何在 Cocos2D 中隐藏 iAd
【发布时间】:2014-04-17 16:44:49
【问题描述】:

AppDelegate.m中有查看banner的代码:

if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone && [UIScreen mainScreen].bounds.size.height == 960.){
    bannerView = [[ADBannerView alloc]initWithFrame:
                  CGRectMake(0, 25, 320, 80)];
}
else{
        bannerView = [[ADBannerView alloc]initWithFrame:
                      CGRectMake(0, 25, 320, 80)];
        // Optional to set background color to clear color
        [bannerView setBackgroundColor:[UIColor clearColor]];
        [viewController.view addSubview: bannerView];

}

如何在 GameLayerView 上隐藏横幅?然后在游戏结束后重新展示它。我应该在 GameLayer.m 中写一些东西吗?

【问题讨论】:

    标签: ios cocos2d-iphone iad appdelegate banner


    【解决方案1】:

    您可以通过执行以下操作隐藏广告:

    -(void)hideBannerView{
    
        if (!_adBannerViewIsVisible){
            return;
        }
    
        if (bannerView){
            _adBannerViewIsVisible = false;
    
            [UIView beginAnimations:nil context:nil];
            [UIView setAnimationDuration:0.5];
            [UIView setAnimationCurve:UIViewAnimationCurveEaseOut];
    
            CGRect frame = bannerView.frame;
    
            frame.origin.x = 0.0f;
            frame.origin.y = -bannerView.frame.size.height ;
    
            bannerView.frame = frame;
    
            [UIView commitAnimations];
        }
    }
    

    别忘了在某个地方创建一个BOOL 变量_adBannerViewIsVisible,可能在头文件中。然后,当您想隐藏广告时,只需拨打[self hideBannerView]

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-10-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多