2011-10-12 48 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; 
    } 
}