2012-02-18 54 views
1

我正在切換並正確縮放iAd在portraid和橫向模式下,除了從橫向模式開始查看時。在這種情況下,iAd保持對應於portraid的較窄寬度。然後在將設備旋轉到portraid並回到風景時解決。如何解決它?謝謝。從橫向模式啓動時,iAd不適合寬度

- (void)viewDidLoad 
{ 
    //iAd 

    adView =[[ADBannerView alloc] initWithFrame:CGRectZero]; 

    adView.requiredContentSizeIdentifiers = [NSSet setWithObjects: ADBannerContentSizeIdentifierPortrait, ADBannerContentSizeIdentifierLandscape, nil]; 

    adView.delegate = self; 

    [self.view addSubview:adView]; 

    [super viewDidLoad]; 
} 


- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)orientation duration:(NSTimeInterval)duration { 

    if (UIInterfaceOrientationIsPortrait(orientation)) { 
     adView.currentContentSizeIdentifier = ADBannerContentSizeIdentifierPortrait; 
    } else { 
     adView.currentContentSizeIdentifier = ADBannerContentSizeIdentifierLandscape; 
    } 

} 

回答

1

你不告訴與方向開始AdView的,所以它的默認方向開始。

嘗試增加在viewDidLoad如下:

if (UIInterfaceOrientationIsPortrait([UIDevice currentDevice].orientation)) { 
    adView.currentContentSizeIdentifier = ADBannerContentSizeIdentifierPortrait; 
} else { 
    adView.currentContentSizeIdentifier = ADBannerContentSizeIdentifierLandscape; 
} 
[self.view addSubview:adView]; 
+0

現在,當在橫向模式下啓動大小合適但與人像開始適合像的風景線! – Jaume 2012-02-20 08:57:07

+0

編輯:如果我改變如果和其他內容,所以ADBannerContentSizeIdentifierPortrait景觀和反向,它的作品!但我完全不明白,應該按照你的建議工作,不是嗎? – Jaume 2012-02-20 09:03:47

+2

它工作正常,直到iOS6所有這些屬性都被棄用。現在問題再次提出。 – 2013-03-07 16:10:23