在动画解雇时,iPad上的AdBannerView会在屏幕外滚动视图

时间:2012-04-16 12:17:36

标签: iphone ios ipad iad adbannerview

我在我的应用中的视图控制器上实现了AdBannerView。它在iPhone上工作正常,但在iPad上测试时出现问题。广告显示正常,但是当我关闭wifi来测试解雇时,广告会将窗口内的所有元素都放下来,然后将背景和标签栏留在原位。这只发生在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];
}   

}

1 个答案:

答案 0 :(得分:0)

我的广告视图偏移框位于错误的位置。对于iPhone框架来说恰好是完美的,因为adview的创建足以将广告推向正确的位置。当iPad出现的时候,计算出的偏移将视线从窗口推开,但还不足以重新看到。