我想将admob添加到基础应用委托中,以便我可以拥有一个持久性广告,该广告将显示所有视图,而不是每次更改视图控制器时刷新。 “bannerView_.rootViewController = self;”是我不知道如何在所有视图控制器上工作的问题。如何从基础应用程序委托中获取应用程序上显示的当前视图控制器。
这是我目前在app delegate中的代码
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Create a view of the standard size at the bottom of the screen.
bannerView_ = [[GADBannerView alloc]
initWithFrame:CGRectMake(0.0,
self.window.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 = @"a14e0dssddb01d";
// 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;
// Initiate a generic request to load it with an ad.
[bannerView_ loadRequest:[GADRequest request]];
//[self.window addSubview:navController.view];
[self.window addSubview:bannerView_];
[self.window makeKeyAndVisible];
return YES;
}