在实际的iOS设备上Admob在iOS应用程序中工作,而它在模拟器中工作

时间:2012-02-02 12:02:52

标签: admob

我正在iOS应用程序中集成Admob(iPhone和iPad:通用应用程序)。 在开始我检查admob在模拟器上工作,但当我在设备上安装应用程序,应用程序崩溃并评论admob代码,应用程序工作正常。几天后,我取消注释代码,并在设备中安装应用程序似乎在两个设备上工作,看到不同的2添加横幅。几天后,同样的代码在设备中崩溃,并在模拟器中为admob工作。现在我评论所有屏幕上的Admob代码,除了一个屏幕,app现在正在工作,如果我没有访问没有注释admob代码的屏幕。

请建议我解决方案。我使用下面的代码。

AbMob = [[GADBannerView alloc]                  initWithFrame:方法CGRectMake(0.0,768-50-90,                                           GAD_SIZE_728x90.width,                                       GAD_SIZE_728x90.height)];

AbMob.adUnitID = [Utility getADmobPublisherId];
AbMob.rootViewController = self;

[self.view addSubview:AbMob];
GADRequest *r = [[GADRequest alloc] init];
r.testing = YES;
//---------
r.testDevices = [NSArray arrayWithObjects:GAD_SIMULATOR_ID,@"UDID1",@"UDID2",nil];
//----------
[AbMob loadRequest:r];

提前感谢。

1 个答案:

答案 0 :(得分:0)

试试这个版本。

AbMob = [[GADBannerView alloc] initWithFrame:CGRectMake(
    0.0,
    768-50-90,
    GAD_SIZE_728x90.width,
    GAD_SIZE_728x90.height)];

AbMob.adUnitID = [Utility getADmobPublisherId];
[AbMob setRootViewController:self];

[self.view addSubview:AbMob];
GADRequest *r = [GADRequest request];  // This takes care of reference counts for you.
r.testDevices = [NSArray arrayWithObjects:GAD_SIMULATOR_ID,
                                          @"UDID1",
                                          @"UDID2",
                                          nil];
[AbMob loadRequest:r];