2012-04-16 106 views
0

我在我的應用程序中的視圖控制器上實現了AdBannerView。它在iPhone上運行良好,但在iPad上測試時出現問題。廣告顯示效果不錯,但是當我關閉wifi以測試解散時,廣告會將窗口內的所有元素與它一起放下,並將背景和tabbar留下。這隻發生在iPad上。AdBannerView在iPad上滾動查看屏幕動畫解僱

這裏是我的動畫廣告視圖代碼:

- (void)fixupAdView:(UIInterfaceOrientation)toInterfaceOrientation { 
int adY = 432; 
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) 
{ 
    adY = 955; 
} 
if (_adBannerView != nil) {   
    if (UIInterfaceOrientationIsLandscape(toInterfaceOrientation)) { 
     [_adBannerView setCurrentContentSizeIdentifier: 
     ADBannerContentSizeIdentifierLandscape]; 
    } else { 
     [_adBannerView setCurrentContentSizeIdentifier: 
     ADBannerContentSizeIdentifierPortrait]; 
    }   
    [UIView beginAnimations:@"fixupViews" context:nil]; 
    if (_adBannerViewIsVisible) { 
     NSLog(@"Visible"); 
     CGRect adBannerViewFrame = [_adBannerView frame]; 
     adBannerViewFrame.origin.x = 0; 
     adBannerViewFrame.origin.y = adY - 
     [self getBannerHeight:toInterfaceOrientation]; 

     [_adBannerView setFrame:adBannerViewFrame]; 
     CGRect contentViewFrame = _contentView.frame; 

     contentViewFrame.origin.y = adY + 
     [self getBannerHeight:toInterfaceOrientation]; 

     contentViewFrame.size.height = self.view.frame.size.height - 
     [self getBannerHeight:toInterfaceOrientation]; 

     _contentView.frame = contentViewFrame; 

    } else { 
     NSLog(@"Not Visible"); 
     CGRect adBannerViewFrame = [_adBannerView frame]; 
     adBannerViewFrame.origin.x = 0; 
     adBannerViewFrame.origin.y = adY; 

     [_adBannerView setFrame:adBannerViewFrame]; 
     CGRect contentViewFrame = _contentView.frame; 

     contentViewFrame.origin.y = adY 
     + [self getBannerHeight:toInterfaceOrientation]; 

     contentViewFrame.size.height = self.view.frame.size.height; 

     _contentView.frame = contentViewFrame;    
    } 
    [UIView commitAnimations]; 
} 

}

回答

0

我在錯誤的位置的廣告鑑於我的補償框架。它恰好是iPhone框架的完美選擇,因爲創建廣告足以將廣告推向正確的位置。到了iPad的時候,計算出的偏移量將視圖從視窗中移除,但還不足以回到視圖中。