简体   繁体   English

导航控制器弹出后,iAd横幅不会再出现

[英]iAd banner doesn't reappear after navigation controller pop

I'm running into a problem with my iAd banner view. 我的iAd横幅视图出现问题。 Initially I have a main menu when my app first loads up. 最初,我的应用程序首次加载时,我有一个主菜单。 I have an iAd Banner positioned right off the bottom edge of the view and it is animated to appear once my view appears. 我在视图的底部边缘附近放置了一个iAd横幅广告,它的动画效果是在视图显示后立即显示。 When I press a button to push to another view controller in the navigation controller hierarchy and then press back to return to the main menu, the iAd does not reappear.It only shows up again when I completely restart the app. 当我按下按钮以推送到导航控制器层次结构中的另一个视图控制器,然后再按返回以返回主菜单时,iAd不会重新出现。仅当我完全重新启动该应用程序时它才会再次显示。

Here is my code: 这是我的代码:

//MainMenu. h
@property (strong, nonatomic) IBOutlet ADBannerView *adView;
@property (nonatomic) BOOL bannerIsVisible;


 //MainMenu.m
-(void)viewWillAppear:(BOOL)animated
{
    bannerIsVisible = NO;

    adView.delegate = self;

   [self.navigationController setNavigationBarHidden: YES animated:YES];

}

#pragma Begin Ad View Methods
-(void)bannerViewDidLoadAd:(ADBannerView *)banner
{
    if(bannerIsVisible == NO)
    {
        NSLog(@"Banner ad loaded");

        [UIView beginAnimations:@"animateAdBannerOn" context:NULL];

        banner.frame = CGRectOffset(banner.frame, 0, -banner.frame.size.height);

        [UIView commitAnimations];

        bannerIsVisible = YES;
    }
}

-(void)viewWillDisappear:(BOOL)animated
{
    if(bannerIsVisible == YES)
    {
        [UIView beginAnimations:@"animateBannerOff" context:NULL];

        adView.frame = CGRectOffset(adView.frame, 0, adView.frame.size.height);

        [UIView commitAnimations];

        bannerIsVisible = NO;
    }
}

-(void)bannerView:(ADBannerView *)banner didFailToReceiveAdWithError:(NSError *)error
{
    NSLog(@"Failed to load the ad in main menu: %@", [error localizedDescription]);
}

#pragma End Ad View Methods

I've tried removing the offset methods and just turning the adView.hidden = YES/NO to see if it was an animation problem but the result is the same. 我试过删除偏移方法,只是打开adView.hidden = YES / NO,看是否是动画问题,但结果是相同的。 If anyone could offer tips or help it would be greatly appreciated. 如果有人可以提供提示或帮助,将不胜感激。 I've also tried putting the respective code in other methods like viewDidLoad and viewDidDisappear too. 我也尝试将相应的代码放入其他方法中,例如viewDidLoad和viewDidDisappear。

It is something, 是的

just on your main view, add a View of type UIView, give it a size respecting the size of the add you want to have, 在您的主视图上,添加一个UIView类型的视图,并为其添加一个要尊重您要添加的内容大小的大小,

then instead of loading your ads in the main view, load it in the view you added specifically for the banner 然后将广告加载到专门为横幅添加的视图中,而不是在主视图中加载广告

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM