【问题标题】:AdWhirl rotation usageAdWhirl 轮播使用
【发布时间】:2011-10-12 11:03:58
【问题描述】:

我正在尝试旋转 AdWhirl 横幅视图。 AdWhirl 提供的唯一文档是:

6.2 设备方向 包括 iAd 在内的一些广告网络将根据设备方向改变其广告尺寸。 如果您的应用支持旋转,您必须通过在 UIViewController 的 should/willAutorotateToInterfaceOrientation: 实现中调用 AdWhirlView.rotateToOrientation: 将方向更改转发到 AdWhirlView,然后按照 6.1 进行重新调整。 如果您的应用的方向概念与 UIDevice.orientation 有所不同,您还必须实现 AdWhirlDelegate.adWhirlCurrentOrientation 以返回适当的值。

我正在尝试解决这个问题,目前已正确实施 adWhirlDidReceiveAd 方法,但我无法正确旋转和/或调整相关广告的大小。

【问题讨论】:

    标签: iphone adwhirl


    【解决方案1】:

    在视图底部设置 AdWhirl:here

    在滚动时使广告静止(即 TableView):here

    这就是我使用 AdWhirl 轮播广告的方式(可能不是最佳解决方案...):

        awView.transform = CGAffineTransformIdentity;
        awView.transform = CGAffineTransformMakeRotation(degreesToRadian(-90));
        awView.bounds = CGRectMake(0.0, 0.0, 480, 320);
    

    您需要根据您的视图更改坐标。

    【讨论】:

    • 这是正确的方法吗,因为 bcoz m 无法获得想要的结果?
    【解决方案2】:

    [AdWhirlView rotateToOrientation] 为每个当前网络适配器调用rotateToOrientation 方法。 但是,某些网络适配器不会覆盖此方法。此方法的默认实现什么也不做。 所以,你需要重写 rotateToOrientation 方法。

    接下来是 AdMob 网络适配器的示例实现。

    AdWhirlAdapterGoogleAdMobAds.m

    -(void)rotateToOrientation:(UIInterfaceOrientation)orientation {
    
        GADBannerView* adMobView;
        adMobView = (GADBannerView*)adNetworkView;
    
        switch (orientation) {
            case UIInterfaceOrientationPortrait:
            case UIInterfaceOrientationPortraitUpsideDown:
                adMobView.adSize = kGADAdSizeSmartBannerPortrait;
                break;
            case UIInterfaceOrientationLandscapeLeft:
            case UIInterfaceOrientationLandscapeRight:
                adMobView.adSize = kGADAdSizeSmartBannerLandscape;
                break;
            default:
                break;
        }
    }
    

    【讨论】:

      【解决方案3】:

      在你的 UIViewController 实现中,添加 shouldAutorotateToInterfaceOrientation: 像这样:

      - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
      {
          // Return YES for supported orientations
          if (interfaceOrientation is supported)
          {
              [adWhirlView_ rotateToOrientation:interfaceOrientation];
              return YES;
          }
          else
          {
              return NO;
          }
      }
      

      请注意,只要实现了 shouldAutorotateToInterfaceOrientation:,AdWhirlView 就会随着布局的其余部分旋转。但是,调用 rotateToOrientation: 将告诉 AdWhirlView 将方向更改信号转发给广告,以便单个广告网络可以根据需要针对横向优化广告。

      【讨论】:

      • 我注意到它随着屏幕旋转,但还没有调整广告大小。
      • 顺便说一句,我在文档中的任何地方都找不到如何将广告放置在视图底部,并使其在屏幕中保持静止,这样您就无法将其滚动到视图之外。
      • 在我的情况下,rotateToOrientation currAdapter 的定义总是 nil .....它总是在设置方向之前返回
      猜你喜欢
      • 1970-01-01
      • 2017-05-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-03-10
      • 2021-10-25
      • 1970-01-01
      相关资源
      最近更新 更多