iAds leaving white block when unable to show

柔情痞子 提交于 2019-12-04 04:56:09

问题


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.


回答1:


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

Error Handling

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.

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

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

{

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.

Hope this helps you




回答2:


very old question so will get shot down for answering, but I found this thread when I needed the answer. I since found the answer and thought I should post in incase others stumble upon this thread as I did.

in IB the bannerView has a background colour. Set it to same colour as your background :-) clear color if doing is code maybe

Also remember to start the banner view as hidden. So it only appears when view is shown. if its starts unhidden then it will try to load an ad fail then disappear. which is why you get the white space. set hidden in IB or in viewdidload method



来源:https://stackoverflow.com/questions/7767102/iads-leaving-white-block-when-unable-to-show

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!