AdMob在iOS模拟器中没有展示广告

8
我正在尝试在一个适用于iOS 4.0的应用程序上使用AdMob。
我已经添加了教程http://code.google.com/mobile/ads/docs/ios/fundamentals.html中提供的示例代码(我已更改adUnitID):
// Create a view of the standard size at the bottom of the screen.
bannerView_ = [[GADBannerView alloc]
               initWithFrame:CGRectMake(0.0,
                                        self.view.frame.size.height -
                                        GAD_SIZE_320x50.height,
                                        GAD_SIZE_320x50.width,
                                        GAD_SIZE_320x50.height)];

// Specify the ad's "unit identifier." This is your AdMob Publisher ID.
bannerView_.adUnitID = @"XYZ";

// Let the runtime know which UIViewController to restore after taking
// the user wherever the ad goes and add it to the view hierarchy.
bannerView_.rootViewController = self;
[self.view addSubview:bannerView_];
[self.view bringSubviewToFront:bannerView_];

GADRequest * request = [GADRequest request];

// Initiate a generic request to load it with an ad.
[bannerView_ loadRequest:request];

运行这段代码时,没有任何反应,广告也没有展示出来,但AdMob应用页面的请求次数会不规律地增加(即:我似乎无法注意到模式),但最重要的是没有广告展示。

如果我添加以下代码:

GADRequest * request = [GADRequest request];

request.testDevices = [NSArray arrayWithObjects:
                       GAD_SIMULATOR_ID,                               // Simulator
                       nil];

// Initiate a generic request to load it with an ad.
[bannerView_ loadRequest:request];

我收到了“成功!您现在可以通过应用程序星系旅行”默认横幅,但只有这一个。
所以我的问题是:
  • 示例代码不足以显示广告吗?为什么我从未看到过带有示例代码的广告?
  • 据我所知,请求意味着我的应用程序请求展示广告的次数。我也明白,并非每个请求都会回复广告(否则填充率将达到100%),但仍然从未看到过广告,我做错了什么?
提前感谢。
3个回答

4
  GADBannerView *bannerView = [[GADBannerView alloc]
              initWithFrame:CGRectMake(0.0,
                                       self.view.frame.size.height -
                                       GAD_SIZE_320x50.height,
                                       GAD_SIZE_320x50.width,
                                       GAD_SIZE_320x50.height)];//Set Position

  bannerView.adUnitID = @"12331255421245";//Call your id

// Let the runtime know which UIViewController to restore after taking
// the user wherever the ad goes and add it to the view hierarchy.


bannerView.rootViewController = self;

[self.view addSubview:bannerView];//Your attempt to add bannerview


// Initiate a generic request to load it with an ad.

[bannerView loadRequest:[GADRequest request]];

0

我设置了以上所有方法。广告横幅在设备上看起来正常,但在模拟器中不显示广告。

我将设备ID设置为GAD_SIMULATOR_ID,但它并没有起作用。它的委托方法没有被调用。!!


-3

请在设备上尝试。模拟器中的应用程序不会显示Admob广告。


我也遇到类似的困难,设备也没有改善。还有其他建议吗? - Oded Ben Dov
1
检查您是否已注册有效的adUnitID。如果是,则将其放置在以下位置: GADBannerView *bannerView = [[GADBannerView alloc] initWithFrame:CGRectMake(0.0, self.view.frame.size.height - GAD_SIZE_320x50.height - 42, GAD_SIZE_320x50.width, GAD_SIZE_320x50.height)]; bannerView.adUnitID = MY_BANNER_AD_ID; 如果您还没有注册,请从这里开始:http://www.admob.com/register - rushafi
1
最终,这是由于运行新的单元ID时出现的延迟。几天后我又遇到了同样的问题,因为没有人使用该应用程序,但现在它已经激活,广告也会显示出来。 - Oded Ben Dov
@rushafi 在模拟器中确实会显示广告。 - Lukas Wiklund

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接