-(void)resetAdView:(UIViewController *)rootViewController {
currentDelegate_ = rootViewController;
if (ADloads) {
[rootViewController.view addSubview:adBanner_];
adBanner_.delegate = self;
adBanner_.rootViewController = rootViewController;
adBanner_.adUnitID = @"Unit-ID";
GADRequest *request = [GADRequest request];
[adBanner_ loadRequest:request];
ADloads = YES;
request.testDevices= @[ GAD_SIMULATOR_ID ];
} else {
adBanner_.delegate = self;
adBanner_.rootViewController = rootViewController;
adBanner_.adUnitID = @"Unit-ID";
GADRequest *request = [GADRequest request];
[adBanner_ loadRequest:request];
[rootViewController.view addSubview:adBanner_];
ADloads = YES;
request.testDevices= @[ GAD_SIMULATOR_ID ];
}
}
无法理解为什么AdMob只发送真实广告而不是我要求的测试广告。它只发送真实广告的代码有什么问题?
答案 0 :(得分:1)
[adBanner_ loadRequest:request]; // send request
[rootViewController.view addSubview:adBanner_];
ADloads = YES;
request.testDevices= @[ GAD_SIMULATOR_ID ] // modify request to add test device
您将模拟器添加为测试设备的行是之后发送请求的行。该请求已经在前往服务器的途中。太晚了。
尝试重新排序您的陈述,看看会发生什么。