我在我的应用中使用以下代码(viewDidLoad
方法)来展示AdMob广告:
// Create a view of the standard size at the bottom of the screen.
// Available AdSize constants are explained in GADAdSize.h.
bannerView_ = [[GADBannerView alloc] initWithAdSize:kGADAdSizeBanner];
// Specify the ad's "unit identifier." This is your AdMob Publisher ID.
bannerView_.adUnitID = @"ABC";
// 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_];
// Initiate a generic request to load it with an ad.
[bannerView_ loadRequest:[GADRequest request]];
如果我在其他应用程序或此应用程序的表视图(根视图控制器)中使用该代码,则广告显示正常。在UIWebView
中使用它并没有任何反应。
任何人都可以建议问题可能是什么?
答案 0 :(得分:0)
当你说'在你UIWebView
'中使用它时,你的意思是什么?
您是否将GADBannerView
作为子视图添加到UIWebView
?因为那不行。您最好减少UIWebView
的高度,并将GADBannerView
添加到某种类型的容器视图中,该视图也包含您的UIWebView
。
基本上,在视图层次结构中创建UIWebView
和GADBannerView
兄弟。