AdMob广告没有出现在iPhone模拟器
问题描述:
我试图使用AdMob上的应用内广告(内置于iOS 4.0)AdMob广告没有出现在iPhone模拟器
我增加可用的样本代码在本教程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];
我得到的!“的成功,你现在可以通过App银河去旅行”默认标题,但只有这一个。
所以我的问题是:
- 不是示例代码足以显示广告?为什么我从来没有看到带有示例代码的广告?
- 据我了解,请求意味着我的应用程序要求显示广告的次数。我也明白,并不是每个请求都会回复一个广告(否则填充率将是100%),但仍然是,我从未看过广告,我做错了什么?
在此先感谢。
答
在设备中尝试。模拟器中的应用不会显示Admob广告。
答
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]];
答
我设置了上述所有方法。广告横幅在设备中正常显示,但未在模拟器中显示广告。
我将设备ID设置为GAD_SIMULATOR_ID,但它不起作用。它的委托方法没有被调用。 !
我遇到了类似的困难,而且该设备并不好。另一个建议? – 2011-08-24 11:35:49
检查您是否注册了有效的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 2011-08-30 19:04:33
最终,当你运行一个新的单元ID时,它会产生滞后效应。几天后,我再次使用了它,因为没有人使用该应用程序,但现在它已启动,广告显示出来。 – 2011-08-31 10:04:41