- (UIView *)addbanner{
CGPoint origin = CGPointMake(0.0, 0);
self.adBanner = [[[GADBannerView alloc] initWithAdSize:kGADAdSizeBanner origin:origin]autorelease];
headerView = [[[UIView alloc] initWithFrame:CGRectMake(0,0,320, self.adBanner.adSize.size.height)] autorelease];
self.adBanner.adUnitID = @"a14fe853330ee80";
self.adBanner.delegate = self;
[self.adBanner setRootViewController:self];
[headerView addSubview:self.adBanner];
[self.adBanner loadRequest:[self createRequest]];
return headerView;
}
- (GADRequest *)createRequest {
GADRequest *request = [GADRequest request];
request.testing = NO;
return request;
}
- (void)bannerView:(GADBannerView *)banner didFailToReceiveAdWithError:(NSError *)error
{
NSLog(@"error %@", error);
}
- (void)adViewDidReceiveAd:(GADBannerView *)bannerView
{
NSLog(@"success");
}
当我在 iOS 5 设备上尝试开发者和分发模式时也可以显示。
当我在开发人员和分发模式下尝试 iOS 6 设备但无法显示时。
这是我的应用程序。