我在屏幕底部添加了一个横幅视图,用于实施 iAd。但是在模拟器上运行时,横幅视图略高于为其固定的框架。它显示为透明条,不可选择。一段时间后,它会自动以黑色条带的形式出现在底部,上面写着测试广告。
我希望横幅视图粘在底部而不是动画。
这是我的代码。adView 声明代码:
adView = [[[ADBannerView alloc] initWithFrame:CGRectOffset(CGRectZero, 0, 350)] autorelease];
adView.frame = CGRectMake(0,340,320,25);
adView.requiredContentSizeIdentifiers = [NSSet setWithObject:ADBannerContentSizeIdentifier320x50];
adView.currentContentSizeIdentifier = ADBannerContentSizeIdentifier320x50;
adView.autoresizingMask = UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleRightMargin;
adView.tag = 111;
[self.navigationController.view addSubview:adView];
adView.delegate = self;
self.bannerIsVisible = NO;
adView.hidden = YES;
这是委托方法。
- (void)bannerViewDidLoadAd:(ADBannerView *)banner
{
if (!self.bannerIsVisible) {
[UIView beginAnimations:@"animateAdBannerOff" context:NULL];
// banner is invisible now and moved out of the screen on 50 px
banner.frame = CGRectOffset(banner.frame, 0, 50);
[UIView commitAnimations];
self.bannerIsVisible = YES;
}
}
// When iAd is not availale on the banner
- (void)bannerView:(ADBannerView *)banner didFailToReceiveAdWithError:(NSError *)error
{
if (self.bannerIsVisible) {
[UIView beginAnimations:@"animateAdBannerOff" context:NULL];
// banner is visible and we move it out of the screen, due to connection issue
banner.frame = CGRectOffset(banner.frame, 0, 520);
[UIView commitAnimations];
self.bannerIsVisible = NO;
}
}
我无法理解这个问题。请帮忙。