我的应用刚刚被拒绝,因为“只要 iAd 不提供广告内容,应用内的横幅就应该隐藏。” 然后他们提供这个示例代码;
- (void)bannerView:(ADBannerView *)banner didFailToReceiveAdWithError:(NSError *)error
{
if (self.bannerIsVisible)
{
[UIView beginAnimations:@"animateAdBannerOff" context:NULL];
// assumes the banner view is at the top of the screen.
banner.frame = CGRectOffset(banner.frame, 0, -banner.frame.size.height);
[UIView commitAnimations];
self.bannerIsVisible = NO;
}
}
现在我的 iAd 显示在屏幕底部而不是顶部。我还想计算 3.5 和 4 英寸的屏幕,所以这是我的代码;
- (void)bannerView:(ADBannerView *)banner didFailToReceiveAdWithError:(NSError *)error
{
if (self.bannerIsVisible)
{
[UIView beginAnimations:@"animateAdBannerOff" context:NULL];
CGSize result = [[UIScreen mainScreen] bounds].size;
CGFloat scale = [UIScreen mainScreen].scale;
result = CGSizeMake(result.width * scale, result.height * scale);
if(result.height == 1136){
banner.frame = CGRectOffset(banner.frame, 498, -banner.frame.size.height);
}else{
banner.frame = CGRectOffset(banner.frame, 410, -banner.frame.size.height);
}
[UIView commitAnimations];
self.bannerIsVisible = NO;
}
}
真正烦人的部分是我的代码在我的测试 iPhone 和 iOS 模拟器上都能正常工作。
我究竟做错了什么?