2

我想bannerViewActionDidFinish:在点击完成后尝试测试。

我的经验是,在调试版本或模拟器中使用虚假广告进行测试时。有没有人能够成功测试这个?

bannerViewActionShouldBegin:willLeaveApplication:总是用 调用willLeave == NO,当单击测试 iAd 时,会出现确认信息,告诉我 iAd 设置正确……但在关闭该窗口后,bannerViewActionDidFinish:从未调用过。

更多信息:iAd 横幅都在测试中正确显示和消失,并且它们在应用商店分发版本中构建和运行良好......直到用户从点击操作返回。我想用bannerViewActionDidFinish:这个,但我看不到用假广告测试它的方法。

这是相关代码(希望任何帮助的人都不需要查看布局代码;它似乎总是根据广告是否加载到横幅中,或者是否生成的错误发生与否,也匹配相应的日志输出;唯一没有发生的是bannerViewActionDidFinish:在测试期间从未调用过:

#pragma mark - ADBannerViewDelegate implementation
#pragma mark @optional

#if __IPHONE_OS_VERSION_MAX_ALLOWED > __IPHONE_4_3
// This method is invoked when the banner has confirmation that an ad will be presented, but
// before the ad has loaded resources necessary for presentation.
- (void)bannerViewWillLoadAd:(ADBannerView *)banner {
    if (banner == self.adBannerView)
#if DEBUG
        NSLog(@"(%@)bannerViewWillLoadAd", self.navigationItem.title),
#endif
        banner.hidden = NO;
#if DEBUG
    else
        NSLog(@"== banner that will load ad is different than this view's banner ==");
#endif
}
#endif

// This method is invoked each time a banner loads a new advertisement. Once a banner has
// loaded an ad, it will display that ad until another ad is available. The delegate might
// implement this method if it wished to defer placing the banner in a view hierarchy until the
// banner has content to display.
- (void)bannerViewDidLoadAd:(ADBannerView*)banner {
#if DEBUG
    NSLog(@"(%@)bannerViewDidLoadAd: bannerLoaded==%d",
          self.navigationItem.title, banner.isBannerLoaded ? 1 : 0);
#endif
    if (self.view.window)
        [UIView animateWithDuration:0.3 animations:^{
            [self.view setNeedsLayout];
            [self.view layoutIfNeeded];
        }];
#if DEBUG
    else
        NSLog(@"(%@)bannerViewDidLoadAd: window not visible, skipping …",
              self.navigationItem.title);
#endif
}

// This method will be invoked when an error has occurred attempting to get advertisement content.
// The ADError enum lists the possible error codes.
- (void)bannerView:(ADBannerView*)banner didFailToReceiveAdWithError:(NSError *)error {
#if DEBUG
    NSLog(@"(%@)%@: bannerLoaded==%d",
          self.navigationItem.title, error, banner.isBannerLoaded ? 1 : 0);
#endif
    if (self.view.window)
    {
        banner.hidden = !banner.isBannerLoaded; // can't say NO, in case banner loaded w/error!
        [UIView animateWithDuration:0.3 animations:^{
            [self.view setNeedsLayout];
            [self.view layoutIfNeeded];
        }];
    }
#if DEBUG
    else
        NSLog(@"(%@)%s window not visible, skipping…",
              self.navigationItem.title, __FUNCTION__);
#endif
}

// This message will be sent when the user taps on the banner and some action is to be taken.
// Actions either display full screen content in a modal session or take the user to a different
// application. The delegate may return NO to block the action from taking place, but this
// should be avoided if possible because most advertisements pay significantly more when
// the action takes place and, over the longer term, repeatedly blocking actions will
// decrease the ad inventory available to the application. Applications may wish to pause video,
// audio, or other animated content while the advertisement's action executes.

- (BOOL)bannerViewActionShouldBegin:(ADBannerView*)banner willLeaveApplication:(BOOL)willLeave {
    return YES;
}


// This message is sent when a modal action has completed and control is returned to the
// application.  Games, media playback, and other activities that were paused in response to the
// beginning of the action should resume at this point.

- (void)bannerViewActionDidFinish:(ADBannerView *)banner {
    // all new code, to be tested
    [self configureView];
    [UIView animateWithDuration:0.3 animations:^{
        [self.view setNeedsLayout];
        [self.view layoutIfNeeded];
    }];
}
4

0 回答 0