使用iAds dismissModalViewController。横幅视图包含广告但可能会被遮盖

时间:2011-09-01 13:29:46

标签: iphone objective-c ios xcode iad

继承我的问题。我有一个使用PresentModalViewAnimated显示的登录屏幕。一旦用户登录它就被解雇。

在登录界面我有一个iAd,但当它被解雇时,我收到了这个错误。

  

ADBannerView:警告横幅视图(0x5a37df0)有广告,但可能是   模糊。此消息仅在每个横幅视图中打印一次

当我登录然后退出时,iAd不会再次显示。

我的代码片段

    @synthesize bannerIsVisible;

- (void)bannerViewDidLoadAd:(ADBannerView *)banner
{
    if (!self.bannerIsVisible)
    {
        [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];
        self.bannerIsVisible = YES;
    }
}

- (void)bannerView:(ADBannerView *)banner didFailToReceiveAdWithError:(NSError *)error
{
    if (self.bannerIsVisible)
    {
        [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];
        self.bannerIsVisible = NO;
    }
}

- (BOOL)bannerViewActionShouldBegin:(ADBannerView *)banner willLeaveApplication:(BOOL)willLeave
{
    NSLog(@"Banner view is beginning an ad action");
    BOOL shouldExecuteAction = YES;
    if (!willLeave && shouldExecuteAction)
    {
        // stop all interactive processes in the app
        // [video pause];
        // [audio pause];
    }
    return shouldExecuteAction;
}

- (void)bannerViewActionDidFinish:(ADBannerView *)banner
{
    // resume everything you've stopped
    // [video resume];
    // [audio resume];
}


    - (void)viewDidLoad
{
    interestingTags = [[NSSet alloc] initWithObjects: INTERESTING_TAG_NAMES2]; //set interestingTag var to define
    self.userArray = [[NSMutableArray alloc] init]; //init the userArray

    adView = [[ADBannerView alloc] initWithFrame:CGRectZero];
    adView.frame = CGRectOffset(adView.frame, 0, -50);
    adView.requiredContentSizeIdentifiers = [NSSet setWithObject:ADBannerContentSizeIdentifierPortrait];
    adView.currentContentSizeIdentifier = ADBannerContentSizeIdentifierPortrait;
    [self.view addSubview:adView];

    adView.delegate=self;
    self.bannerIsVisible=NO;

    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
}

1 个答案:

答案 0 :(得分:0)

我认为通过这个你可以消除错误。只需删除ViewWillDisappear中的横幅视图:

-(void)viewWillDisappear:(BOOL)animated
{
    [bannerView removeFromSuperview];
}