我正在尝试在应用上使用AdMob(适用于iOS 4.0)
我添加了教程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 Galaxy”默认横幅,但只有这一个。
所以我的问题是:
提前致谢。
答案 0 :(得分: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]];
答案 1 :(得分:0)
我设置了以上所有方法。广告横幅在设备中正常显示,但未在模拟器中显示广告。
我将设备ID设置为GAD_SIMULATOR_ID。但它不起作用。它的委托方法没有被调用。 !!
答案 2 :(得分:-4)
在设备中试用。模拟器中的应用不会显示Admob广告。