in your .h
#import "GADBannerView.h"
#import "RootViewController.h"
....
GADBannerView *bannerView;
RootViewController *controller;
....
Then in your .m
controller = [[RootViewController alloc]init];
controller.view.frame = CGRectMake(0,0,size.width,size.height);
CGSize size = [[CCDirector sharedDirector] winSize];
if (iPad && !retina){
bannerView = [[GADBannerView alloc]
initWithFrame:CGRectMake(size.width/2-364,
size.height -
GAD_SIZE_728x90.height*3.5,
GAD_SIZE_728x90.width,
GAD_SIZE_728x90.height)];
}
else { // It's an iPhone
bannerView = [[GADBannerView alloc]
initWithFrame:CGRectMake(size.width/2-160,
size.height -
GAD_SIZE_320x50.height*3,
GAD_SIZE_320x50.width,
GAD_SIZE_320x50.height)];
}
bannerView.adUnitID = @"XXXXXXXXXXXXX"; // your admob id
bannerView.rootViewController = controller;
[bannerView loadRequest:[GADRequest request]];
[controller.view addSubview:bannerView];
[[[CCDirector sharedDirector] openGLView]addSubview : controller.view];
And to remove it:
[bannerView release];
[controller.view removeFromSuperview];
[controller release];
That works fine for me in all of my games as "Star Connect", perhaps it can be done in a better way so if anyone wants to update it... :)