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