<i id='IO6tg'><tr id='IO6tg'><dt id='IO6tg'><q id='IO6tg'><span id='IO6tg'><b id='IO6tg'><form id='IO6tg'><ins id='IO6tg'></ins><ul id='IO6tg'></ul><sub id='IO6tg'></sub></form><legend id='IO6tg'></legend><bdo id='IO6tg'><pre id='IO6tg'><center id='IO6tg'></center></pre></bdo></b><th id='IO6tg'></th></span></q></dt></tr></i><div id='IO6tg'><tfoot id='IO6tg'></tfoot><dl id='IO6tg'><fieldset id='IO6tg'></fieldset></dl></div>
    <bdo id='IO6tg'></bdo><ul id='IO6tg'></ul>

    1. <legend id='IO6tg'><style id='IO6tg'><dir id='IO6tg'><q id='IO6tg'></q></dir></style></legend>
    2. <small id='IO6tg'></small><noframes id='IO6tg'>

        <tfoot id='IO6tg'></tfoot>
      1. iOS 7 iAd cocos2d 已弃用

        时间:2024-04-14

        <small id='ArFe1'></small><noframes id='ArFe1'>

      2. <legend id='ArFe1'><style id='ArFe1'><dir id='ArFe1'><q id='ArFe1'></q></dir></style></legend>
          <tfoot id='ArFe1'></tfoot>

                <bdo id='ArFe1'></bdo><ul id='ArFe1'></ul>

                  <tbody id='ArFe1'></tbody>
                1. <i id='ArFe1'><tr id='ArFe1'><dt id='ArFe1'><q id='ArFe1'><span id='ArFe1'><b id='ArFe1'><form id='ArFe1'><ins id='ArFe1'></ins><ul id='ArFe1'></ul><sub id='ArFe1'></sub></form><legend id='ArFe1'></legend><bdo id='ArFe1'><pre id='ArFe1'><center id='ArFe1'></center></pre></bdo></b><th id='ArFe1'></th></span></q></dt></tr></i><div id='ArFe1'><tfoot id='ArFe1'></tfoot><dl id='ArFe1'><fieldset id='ArFe1'></fieldset></dl></div>
                  本文介绍了iOS 7 iAd cocos2d 已弃用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我试图将 iAd 实现到我用 cocos2d 制作的 iOS 7 游戏中,我在 xcode 中添加了 iad 框架并进行了以下设置

                  Im trying to get iAd implemented to a iOS 7 game I made with cocos2d, I added iad framework in xcode and have the setup below

                  在@implementation中我已经设置了

                  in @implementation I have set

                     ADBannerView *_bannerView;
                  

                  然后

                  -(id)init
                  {
                      if( (self= [super init]) )
                      {
                          // On iOS 6 ADBannerView introduces a new initializer, use it when available.
                          if ([ADBannerView instancesRespondToSelector:@selector(initWithAdType:)]) {
                              ADBannerView *_adView = [[ADBannerView alloc] initWithAdType:ADAdTypeBanner];
                  
                          } else {
                              _adView = [[ADBannerView alloc] init];
                          }
                          _adView.requiredContentSizeIdentifiers = [NSSet setWithObject:ADBannerContentSizeIdentifierPortrait];
                          _adView.currentContentSizeIdentifier = ADBannerContentSizeIdentifierPortrait;
                          [[[CCDirector sharedDirector]view]addSubview:_adView];
                          [_adView setBackgroundColor:[UIColor clearColor]];
                          [[[CCDirector sharedDirector]view]addSubview:_adView];
                          _adView.delegate = self;
                      }
                      [self layoutAnimated:YES];
                      return self;
                  }
                  
                  
                  - (void)layoutAnimated:(BOOL)animated
                  {
                      // As of iOS 6.0, the banner will automatically resize itself based on its width.
                      // To support iOS 5.0 however, we continue to set the currentContentSizeIdentifier appropriately.
                      CGRect contentFrame = [CCDirector sharedDirector].view.bounds;
                      if (contentFrame.size.width < contentFrame.size.height) {
                          //_bannerView.currentContentSizeIdentifier = ADBannerContentSizeIdentifierPortrait;
                          [adView setAutoresizingMask:UIViewAutoresizingFlexibleWidth];
                      } else {
                          _bannerView.currentContentSizeIdentifier = ADBannerContentSizeIdentifierLandscape;
                      }
                  
                      CGRect bannerFrame = _bannerView.frame;
                      if (_bannerView.bannerLoaded) {
                          contentFrame.size.height -= _bannerView.frame.size.height;
                          bannerFrame.origin.y = contentFrame.size.height;
                      } else {
                          bannerFrame.origin.y = contentFrame.size.height;
                      }
                  
                      [UIView animateWithDuration:animated ? 0.25 : 0.0 animations:^{
                          _bannerView.frame = bannerFrame;
                      }];
                  }
                  
                  - (void)bannerViewDidLoadAd:(ADBannerView *)banner {
                      [self layoutAnimated:YES];
                  }
                  
                  - (void)bannerView:(ADBannerView *)banner didFailToReceiveAdWithError:(NSError *)error {
                      [self layoutAnimated:YES];
                  }
                  

                  我收到一个关于_adview"的错误,以及不推荐使用的currentContentSizeIdentifier",谁能帮我让它正常工作吗?我在网上查了一整天,没有任何代码可以工作.

                  I get an error about '_adview' and as well as 'currentContentSizeIdentifier' deprecated, can anyone help me get this working correctly? Ive checked online all day and couldnt get any of the code working.

                  提前致谢!

                  推荐答案

                  试试这个新代码:

                  - (void)createAdBannerView
                  {
                      _adBannerView = [[ADBannerView alloc] initWithFrame:CGRectZero];
                      _adBannerView.delegate = self;
                     [_adBannerView setAutoresizingMask:UIViewAutoresizingFlexibleWidth];
                  
                      CGRect frame = _adBannerView.frame;
                      frame.origin.y = -frame.size.height;
                      frame.origin.x = 0.0f;
                  
                      _adBannerView.frame = frame;
                  
                      AppDelegate * app = (((AppDelegate*) [UIApplication sharedApplication].delegate));
                      [app.navController.view addSubview:_adBannerView];
                  }
                  

                  这里是 Cocos2d 3.0 的新 iAd 代码.

                  这篇关于iOS 7 iAd cocos2d 已弃用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:在 AppDelegate 中调用函数? 下一篇:在 Box2d/Cocos2d for iPhone 中应用涡流/漩涡效果

                  相关文章

                2. <tfoot id='HEBWp'></tfoot>
                  <legend id='HEBWp'><style id='HEBWp'><dir id='HEBWp'><q id='HEBWp'></q></dir></style></legend>
                  <i id='HEBWp'><tr id='HEBWp'><dt id='HEBWp'><q id='HEBWp'><span id='HEBWp'><b id='HEBWp'><form id='HEBWp'><ins id='HEBWp'></ins><ul id='HEBWp'></ul><sub id='HEBWp'></sub></form><legend id='HEBWp'></legend><bdo id='HEBWp'><pre id='HEBWp'><center id='HEBWp'></center></pre></bdo></b><th id='HEBWp'></th></span></q></dt></tr></i><div id='HEBWp'><tfoot id='HEBWp'></tfoot><dl id='HEBWp'><fieldset id='HEBWp'></fieldset></dl></div>

                  • <bdo id='HEBWp'></bdo><ul id='HEBWp'></ul>

                  <small id='HEBWp'></small><noframes id='HEBWp'>