IAd left white blank screen after closing

I had a problem with iAd integration in iPhone applications - an ad in a banner is great when it is spent (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 could not understand why. This is how I integrate the ad:

Since I need to support other ads for the lower version of iPhone OS, I add a container view at the top of the applications whose view controller is AdViewController. When the view is loaded, I create AdBannerView programmatically and add it as a subview in 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
    }

The following are delegate methods:

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;
}
}
+3
source share
3 answers

. , ADBannerView . , AdBannerView adView, 320x50. , . , iAd, , , - .

+4

, , y. , . , .

-(void) bannerViewActionDidFinish:(UIView *)inBanner {
    CGRect                      frame = [inBanner frame];

    frame.origin.x = frame.size.width * 0.5;
    frame.origin.y = frame.size.height * 0.5;

    [inBanner setCenter:frame.origin];
}
+1
Hey David! I know what you mean, I also use my own ad controller, which calls up various ad networks.

So, iAd is not in full screen mode, but inside the 320x50 view.

Just do the following:

-(void) bannerViewActionDidFinish:(ADBannerView *)inBanner {

[self.view setFrame:CGRectMake(0.0f, 0.0f, 320.0f, 50.0f)];

}

Thus, the appearance of the container (self.view) changes to its original size. iAd resizes in full screen to display ads when iAd is displayed.

+1
source

Source: https://habr.com/ru/post/1752846/


All Articles