无法显示时,iAd会留白 [英] iAds leaving white block when unable to show

查看:58
本文介绍了无法显示时,iAd会留白的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

自从更新到iOS 5以来,iAds出现问题.我发现,当广告无法显示时,它会显示一个大的白色块,通常会显示iAd.有没有办法解决这个问题?我尝试将iAd的背景色设置为与UIView的背景色匹配,但这没用.

I'm having an issue with iAds since updating to iOS 5. I found that when the ads can't be displayed it is showing a large white block where the iAd would normally be. Is there a way to resolve this issue? I tried setting the background colour of the iAd to match my UIView's background colour but that didn't work.

推荐答案

我认为您应该移动屏幕的横幅,如以下示例所示,该示例可以为

I think you should just move the banner of screen as shown in the following example that can be here

错误处理

如果发生错误,则横幅视图将调用委托人的bannerView:didFailToReceiveAdWithError:方法.发生这种情况时,您的应用程序必须隐藏横幅视图.清单2-3显示了一种实现此目标的方法.它使用与清单2-2相同的属性来跟踪横幅是否可见.如果标语可见并且发生错误,它将标语移出屏幕.

If an error occurs, the banner view calls the delegate’s bannerView:didFailToReceiveAdWithError: method. When this happens, your application must hide the banner view. Listing 2-3 shows one way you might implement this. It uses the same property as Listing 2-2 to keep track of whether the banner is visible. If the banner is visible and an error occurs, it moves the banner off the screen.

清单2-3在没有广告的情况下删除横幅视图

Listing 2-3 Removing a banner view when advertisements are not available

  • (void)bannerView:(ADBannerView *)banner didFailToReceiveAdWithError:(NSError *)error

{

如果(self.bannerIsVisible)

if (self.bannerIsVisible)

{

   [UIView beginAnimations:@"animateAdBannerOff" context:NULL];

//假设横幅视图位于屏幕底部.

// Assumes the banner view is placed at the bottom of the screen.

   banner.frame = CGRectOffset(banner.frame, 0, banner.frame.size.height);

   [UIView commitAnimations];

   self.bannerIsVisible = NO;

}

}

即使在将错误发送给您的代表之后,横幅视图仍继续尝试下载新的广告.因此,同时实现这两种委托方法将使您的应用程序仅在加载广告时显示横幅.

Even after an error is sent to your delegate, the banner view continues to try to download new advertisements. Thus, implementing both of these delegate methods allows your application to display the banner only when advertisements are loaded.

希望这对您有帮助

这篇关于无法显示时,iAd会留白的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆