iAd关闭后留下白色空白屏幕 [英] iAd left white blank screen after closed

查看:111
本文介绍了iAd关闭后留下白色空白屏幕的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的iPhone应用程序中集成iAd时遇到了问题 - 横幅广告在消费时很好(参见 http://www.clingmarks.com/iAd1.png http:// www.clingmarks.com/iAd2.png )但是,当我关闭它时,它会留下一个白色的空白屏幕(参见 http://www.clingmarks.com/iAd3.png )。我无法弄清楚为什么。以下是我整合广告的方式:

I got a problem to integrate iAd in my iPhone apps -- the banner ad is fine when it expends (see http://www.clingmarks.com/iAd1.png and http://www.clingmarks.com/iAd2.png), however, when I close it, it left a white blank screen (see http://www.clingmarks.com/iAd3.png). I couldn't figure out why. Here is how I integrate the ad:

因为我需要为较低版本的iPhone操作系统支持其他广告,所以我在应用顶部添加了一个容器视图,其中视图控制器是AdViewController。加载视图后,我以编程方式创建AdBannerView并将其作为子视图添加到AdViewController.view。以下是viewDidLoad方法中的代码:

Because I need to support other ads for lower version of iPhone OSes, I add a container view at the top of the apps, whose view controller is AdViewController. When the view is loaded, I create a AdBannerView programmatically and add it as a subview to the AdViewController.view. Here is the code in the viewDidLoad method:

Class adClass = (NSClassFromString(@"ADBannerView"));
if (adClass != nil) {
    iAdView = [[ADBannerView alloc] initWithFrame:CGRectZero];
    iAdView.frame = CGRectOffset(iAdView.frame, 0, -50);
    iAdView.requiredContentSizeIdentifiers = [NSSet setWithObject:ADBannerContentSizeIdentifier320x50];
    iAdView.currentContentSizeIdentifier = ADBannerContentSizeIdentifier320x50;
    iAdView.delegate = self;
    iadViewIsVisible = NO;
    [self.view addSubview:iAdView];
} else {
       // init google adsense
    }

以下是委托方法:

enter code here
- (void)bannerViewDidLoadAd:(ADBannerView *)banner {
if (!iadViewIsVisible) {
    [UIView beginAnimations:@"animateAdBannerOn" context:NULL];
    // banner is invisible now and moved out of the screen on 50 px
    banner.frame = CGRectOffset(banner.frame, 0, 50);
    [UIView commitAnimations];
    iadViewIsVisible = YES;
}
}

- (void)bannerView:(ADBannerView *)banner didFailToReceiveAdWithError:(NSError *)error {
if (iadViewIsVisible) {
    [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, -50);
    [UIView commitAnimations];
    iadViewIsVisible = NO;
}
}


推荐答案

最终我自己弄清楚了。事实证明,ADBannerView的父视图必须是全屏视图。我的上述情况,我将AdBannerView添加到我的adView,这是一个大小为320x50的视图。当我将其父视图更改为全屏视图时,一切正常。我不确定这是否是iAd中的错误,但肯定是棘手的。

Eventually I figured it out myself. It turns out the ADBannerView's parent view must be a fullscreen view. I my case above, I added AdBannerView to my adView, which is a view with size 320x50. When I changed its parent view to a fullscreen view, everything works. I am not sure if this is a bug in iAd, but certainly something tricky.

这篇关于iAd关闭后留下白色空白屏幕的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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