DFP问题:无需展示广告

我的应用在UIScrollView中提供了三个广告(通过DoubleClick for Publisher)。 我使用适用于iOS的旧版AdMob SDK,一切正常。 我决定下载新版本,因为AppStore存在一些问题。 一旦我添加了新版本,我就会收到错误:

Error Domain=com.google.ads Code=1 "Request Error: No ad to show." UserInfo=0x14e88e60 {NSLocalizedDescription=Request Error: No ad to show., NSLocalizedFailureReason=Request Error: No ad to show.} 

广告具有自定义尺寸的广告素材(320×125)。 添加它的UIScrollView是960×125,它被放置为UITableView的标题。

横幅代码:

 - (void)viewDidLoad { [super viewDidLoad]; DFPBannerView *bannerView = (DFPBannerView *)self.view; [self preventBannerCaptureTouch:bannerView]; // Create a view of the standard size at the bottom of the screen. // Available AdSize constants are explained in GADAdSize.h. //bannerView = [[DFPBannerView alloc] initWithAdSize:CG]; bannerView.adSize = GADAdSizeFromCGSize(CGSizeMake(320, 125)); // Specify the ad's "unit identifier." This is your DFP ad unit ID. bannerView.adUnitID = self.adUnitID; [bannerView setAppEventDelegate:self]; [bannerView setDelegate:self]; bannerView.rootViewController = self.bannerOwner; // Initiate a generic request to load it with an ad. GADRequest *request = [[GADRequest alloc] init]; //request.testDevices = [NSArray arrayWithObjects: nil]; [bannerView loadRequest:request]; spinner = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhite]; spinner.center = CGPointMake(self.view.frame.size.width / 2, self.view.frame.size.height / 2); [self.view addSubview:spinner]; [spinner startAnimating]; } - (void)viewDidAppear:(BOOL)animated { [super viewDidAppear:animated]; } - (void)preventBannerCaptureTouch:(GADBannerView*)bannerView { for (UIWebView *webView in bannerView.subviews) { if ([webView isKindOfClass:[UIWebView class]]) { webView.scrollView.bounces = NO; for (UIGestureRecognizer *gestureRecognizer in webView.gestureRecognizers) { if ([gestureRecognizer isKindOfClass:NSClassFromString(@"GADImpressionTicketGestureRecognizer")]) { gestureRecognizer.delegate = self; } } for (id view in [[[webView subviews] objectAtIndex:0] subviews]) { if ([view isKindOfClass:NSClassFromString(@"UIWebBrowserView")]) { for (UIGestureRecognizer *recognizer in [view gestureRecognizers]) { if ([recognizer isKindOfClass:NSClassFromString(@"UIWebTouchEventsGestureRecognizer")]) { [view removeGestureRecognizer:recognizer]; } } return; } } } [webView setTintColor:[UIColor whiteColor]]; } } - (void)viewWillUnload { [super viewWillUnload]; DFPBannerView *bannerView = (DFPBannerView *)self.view; bannerView.appEventDelegate = nil; bannerView.delegate = nil; } - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { [self.bannerSlider bannerTouchesBegan:touches withEvent:event]; } - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event { [self.bannerSlider bannerTouchesEnded:touches withEvent:event]; } - (void)adViewDidReceiveAd:(GADBannerView *)bannerView { [spinner stopAnimating]; } - (void)adView:(GADBannerView *)bannerView didFailToReceiveAdWithError:(GADRequestError *)error { NSLog(@"GOOGLE Ad ERROR: %@", error); [spinner stopAnimating]; } 

UIScrollView代码:

 - (void)viewDidLoad { [super viewDidLoad]; UIScrollView *view = (UIScrollView *)self.view; view.bounces = NO; // @"/6499/example/banner" GWBannerController *oneController = [[GWBannerController alloc] initWithNibName:@"BannerView" bundle:nil bannerOwner:self.bannerOwner bannerSlider:self ID:@"/XXX/iOSLeaderBanner_One"]; //GWBannerController *oneController = [[GWBannerController alloc] initWithNibName:@"BannerView" bundle:nil bannerOwner:self.bannerOwner bannerSlider:self ID:@"/6499/example/banner"]; oneController.view.frame = CGRectMake(0, 0, 320, 125); [view addSubview:oneController.view]; [bannerArray addObject:oneController]; GWBannerController *twoController = [[GWBannerController alloc] initWithNibName:@"BannerView" bundle:nil bannerOwner:self.bannerOwner bannerSlider:self ID:@"/XXX/iOSLeaderBanner_Two"]; twoController.view.frame = CGRectMake(320, 0, 320, 125); [view addSubview:twoController.view]; [bannerArray addObject:twoController]; GWBannerController *threeController = [[GWBannerController alloc] initWithNibName:@"BannerView" bundle:nil bannerOwner:self.bannerOwner bannerSlider:self ID:@"/XXX/iOSLeaderBanner_Three"]; threeController.view.frame = CGRectMake(640, 0, 320, 125); [view addSubview:threeController.view]; [bannerArray addObject:threeController]; [view setContentSize:CGSizeMake(960, 125)]; [self startTimer]; } 

广告服务器将返回此邮件主要是因为您的广告单元ID没有广告。 检查您的广告单元ID是否正确。 如果您的横幅宽度/高度为0,您将得到相同的错误。确保您的adUnitID是完美的。