IAds showing Ad error was unloaded from this banner when switching between tabs in UITabBarController

I'm rooting iAds in your app for the first time, and the application itself - it's a simple 5-loose UITabBarController, where the first 4 are tabs UIViewControllerwith UITableViewa built-in, and the last tab - UITableViewController.

Following this guide: http://www.appcoda.com/ios-iad-introduction/ I have successfully implemented iAds, and it appears in the application and works through each delegate method.

I made the first 4 tabs have iAds, but the last tab does not work. This is because the last tab is static UITableView, and I cannot insert it in UIViewController, etc. So, the first 4 tabs have adBannerView. adBannerViewis added from Storyboardto this UIViewController.

Question

During development on a real device running iOS 8.1.1 (and on another device with 8.2), when I am on the first tab, it shows the iAd banner without any problems. When I switch to the second tab and return to the first tab, two things happen:

1) adBannerViewis, but the actual ad itself is displayed for a second, and then disappears again. 2) The delegate method below throws an error as soon as I leave the first tab:

- (void)bannerView:(ADBannerView *)banner didFailToReceiveAdWithError:(NSError *)error
{
    NSLog(@"Unable to show ads. Error: %@", [error localizedDescription]);
}
NSLog: Unable to show ads. Error: The operation couldn’t be completed. Ad was unloaded from this banner. 

, . 5- , adBannerView , , adBannerView .

, NSLogs, , , viewWillAppear, :

- (void)bannerViewWillLoadAd:(ADBannerView *)banner


- (void)bannerViewDidLoadAd:(ADBannerView *)banner

, , 2 , adBannerView. , adBannerView, .

:

- (void)bannerViewWillLoadAd:(ADBannerView *)banner
{
    NSLog(@"AD Banner will load ad");
}

- (void)bannerViewDidLoadAd:(ADBannerView *)banner
{
    NSLog(@"Ad Banner did load ad");

    // We must show the ad banner view when an ad is ready to be displayed.
    [UIView animateWithDuration:0.5 animations:^{
        self.adBanner.alpha = 1.0;
    }];

//    self.adBanner.hidden = NO;

}

- (BOOL)bannerViewActionShouldBegin:(ADBannerView *)banner willLeaveApplication:(BOOL)willLeave
{    
    NSLog(@"Ad Banner action is about to begin");

    return YES;
}

- (void)bannerViewActionDidFinish:(ADBannerView *)banner
{
    NSLog(@"Ad Banner action did finish");
}

- (void)bannerView:(ADBannerView *)banner didFailToReceiveAdWithError:(NSError *)error
{
    NSLog(@"Unable to show ads. Error: %@", [error localizedDescription]);

    // When there are no ads to show, we should hide it:

     Hide the ad banner.
    [UIView animateWithDuration:0.5 animations:^{
        self.adBanner.alpha = 0.0;
    }];

}

- (void)viewDidLoad
{
    [super viewDidLoad];
    self.adBanner.delegate = self;
    self.adBanner.alpha = 0.0;

}

Apple (https://developer.apple.com/library/ios/documentation/UserExperience/Conceptual/iAd_Guide/TestingiAdApplications/TestingiAdApplications.html), , , , , , , .

, Stack Overflow, adBannerView nil viewWillDisappear. , , , , , adBannerView, ,

- (void)viewWillDisappear:(BOOL)animated
{
    NSLog(@"DISAPEARING");
    self.adBanner.delegate = nil;
}

, , , , , NSLog , . , , , , adBannerView, , 2 ,

AppDelegate : https://www.youtube.com/watch?v=_0Mv44FWw0A&feature=youtu.be.

, , , - , 2 , bannerViewDidLoadAd IS , .

.

+4

All Articles