【问题标题】:iAd shows white boxiAd 显示白框
【发布时间】:2013-12-10 08:22:35
【问题描述】:

iAd 有点问题。有时它会显示一个空白的白色框。当我用Admob 尝试它时,它完美无缺。有时横幅正确来自按钮,但有时它会立即显示白框。问题是什么?

这是我的代码:

    -(void)viewDidLayoutSubviews
    {
        if (self.view.frame.size.height != self.iAdBannerView.frame.origin.y)
                    {
            self.iAdBannerView.frame = CGRectMake(0.0, self.view.frame.size.height, self.iAdBannerView.frame.size.width, self.iAdBannerView.frame.size.height);
                                    iAdBannerView.requiredContentSizeIdentifiers= [NSSet setWithObjects: ADBannerContentSizeIdentifierLandscape,nil];
                        iAdBannerView.currentContentSizeIdentifier = ADBannerContentSizeIdentifierLandscape;
                    }

            if (self.view.frame.size.height != self.gAdBannerView.frame.origin.y)
            {
                self.gAdBannerView.frame = CGRectMake(150, self.view.frame.size.height, self.gAdBannerView.frame.size.width, self.gAdBannerView.frame.size.height);
            }

// Hide the banner by sliding down
-(void)hideBanner:(UIView*)banner
{
    if (banner && ![banner isHidden])
    {
        [UIView beginAnimations:@"hideBanner" context:NULL];
        banner.frame = CGRectOffset(banner.frame, 0, banner.frame.size.height);
        [UIView commitAnimations];
        banner.hidden = TRUE;
    }
}

// Show the banner by sliding up
-(void)showBanner:(UIView*)banner
{
    if (banner && [banner isHidden])
    {
        [UIView beginAnimations:@"showBanner" context:NULL];
        banner.frame = CGRectOffset(banner.frame, 0, -banner.frame.size.height);
        [UIView commitAnimations];
        banner.hidden = FALSE;
    }
}

#pragma mark - ADBanner delegate methods -

// Called before the add is shown, time to move the view
- (void)bannerViewWillLoadAd:(ADBannerView *)banner
{
    NSLog(@"iAd load");
    [self hideBanner:self.gAdBannerView];
    [self showBanner:self.iAdBannerView];
}

// Called when an error occured
- (void)bannerView:(ADBannerView *)banner didFailToReceiveAdWithError:(NSError *)error
{
    NSLog(@"iAd error: %@", error);
    [self hideBanner:self.iAdBannerView];
    [self.gAdBannerView loadRequest:[GADRequest request]];
}

【问题讨论】:

    标签: ios7 iad


    【解决方案1】:

    iAds 并不总是加载广告。有一个委托方法可以让您知道广告何时加载成功。

    ADBannerViewDelegatebannerViewDidLoadAd:bannerView:didFailToReceiveAdWithError:

    【讨论】:

    • 我在前面添加了代表
    • 是否调用了委托方法?广告正确显示和不正确显示有区别吗?
    • 你看thisthis了吗?
    • 当它正常工作时,横幅从底部滑动,当它不能正常工作时,底部有一个白框,几秒钟后它会用 iAd 测试文本填充它。另一个解决方案对我不起作用:(
    • 我认为正在发生的事情是您既没有收到广告也没有收到失败,因此您什么也看不到。当横幅隐藏时,您需要在该空间中有一些东西,并将其初始化为该状态。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-12-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多