Adding admob to base appdelegate so it can be persistent thoughout all views
I want to add admob to the base app delegate so that I can have a persistent ad that will show though out all views instead of refreshing the every time i change the view Controllers. "bannerView_.rootViewController = self;" is the problem i do not know how to get this to work across all the view controllers. How can I from the base app delegate be able to get the current viewcontroller displayed on the app.
This is the code that i have currently in 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;
}
精彩评论