Question

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:

Detecting When Advertisements Are Loaded

– bannerViewWillLoadAd:
– bannerViewDidLoadAd:

Detecting When a User Interacts With an Advertisement

– bannerViewActionShouldBegin:willLeaveApplication:
– bannerViewActionDidFinish:

Detecting Errors

– bannerView:didFailToReceiveAdWithError:

Nothings seems to get triggered when the banner unloads.

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

Was it helpful?

Solution

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;
                     }];
}

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;
                     }];
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top