iAd ADBannerView检测到正在卸载 [英] iAd ADBannerView detect unloading

查看:87
本文介绍了iAd ADBannerView检测到正在卸载的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果添加ADBannerView,则可以检测其何时从其委托函数加载AD:

If you add an ADBannerView you can detect when it loads an AD from its delegate function:

- (void)bannerViewDidLoadAd:(ADBannerView *)banner {

如果您在所需横幅下方有视图,这会很有帮助在横幅广告加载时移动或调整大小。

This can be helpful if you have views below the banner that you need to move or resize when the banner loads.

我找不到任何方法来检测横幅何时消失以重新移回所有视图。

I coudn't find any way to detect when the banner is disappearing to move back again all the views in place.

该代表仅具有以下功能:

The delegate has only these functions:

检测何时加载广告

– bannerViewWillLoadAd:
– bannerViewDidLoadAd:

检测用户与之互动时广告

Detecting When a User Interacts With an Advertisement

– bannerViewActionShouldBegin:willLeaveApplication:
– bannerViewActionDidFinish:

检测错误

– bannerView:didFailToReceiveAdWithError:

横幅广告卸载时似乎什么也不会触发。

Nothings seems to get triggered when the banner unloads.

有什么方法可以检测横幅广告的卸载情况或其他解决方法?
谢谢!

Any way to detect the banner unload or any workarounds? Thanks!

推荐答案

当横幅广告时,我使用 bannerViewDidLoadAd 已加载,因此用动画显示此横幅

I use bannerViewDidLoadAd when a banner is load and so show this banner with an animation

#pragma mark - ADBannerViewDelegate
- (void)bannerViewDidLoadAd:(ADBannerView *)banner
{
    NSLog(@"banner loaded");

    // Display BannerView
    _iAdBannerView.hidden = NO;
    [UIView animateWithDuration:0.4f
                     animations:^{
                         _iAdBannerView.alpha = 1.0f;
                     }];
}

我使用 didFailToReceiveAdWithError 卸载横幅广告时(例如,在此处,您可以添加动画来移动视图):

And I use didFailToReceiveAdWithError when the banner is unload (so here, you can add an animation to move your view for example) :

- (void)bannerView:(ADBannerView *)banner didFailToReceiveAdWithError:(NSError *)error
{
    // Print error
    NSLog(@"error banner failed :\n%@", error);

    // Hide BannerView
    [UIView animateWithDuration:0.4f
                     animations:^{
                         _iAdBannerView.alpha = 0.0f;
                     } completion:^(BOOL finished) {
                         _iAdBannerView.hidden = YES;
                     }];
}

这篇关于iAd ADBannerView检测到正在卸载的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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