0

我在我的应用程序的视图控制器上实现了 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];
}   

}

4

1 回答 1

0

我的广告视图的偏移框架位于错误的位置。它恰好适合 iPhone 框架,因为创建了 adview 就足以将广告推送到正确的位置。到了 iPad 的时间,计算出的偏移量将视图推离了窗口,但还不足以回到视图中。

于 2012-04-16T17:07:43.477 回答