2011-10-12 62 views
0

我试图旋转AdWhirl bannerview。唯一的文档的AdWhirl提供的是:AdWhirl旋转使用

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

我试图想出解决办法,到目前为止,正确实施adWhirlDidReceiveAd方法,但我不能正确旋转和/或调整有问题的广告。

回答

1

设置的AdWhirl在视图的底部:here

使广告的静态滚动(即TableView中)时:here

我这是怎么用的AdWhirl(可能不是最好的解决方案旋转广告.. 。):

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

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

+0

这是否正确的方式这样做bcoz米无法获得欲望的结果? – Tornado

0

在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将方向更改信号转发给广告,以便单个广告网络可以优化横向广告(如果选择的话)。

+0

我注意到它与屏幕旋转,但它并没有调整广告呢。 – MaikelS

+0

顺便说一句,我无法找到文档中的任何地方如何将广告放置在视图的底部,并使其在屏幕中静态显示,以便您不能将其滚动到视图外。 – MaikelS

+0

rotateToOrientation的定义currAdapter始终为零在我的情况下.....它始终返回之前设置方向 – Tornado

1

[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; 
    } 
}