I implement successfully admob banner ads in my ios game with cocos2d-x 2.2.2
I use the following code inside AppController.mm
NSLog(@"%f - %f - %f - ",bannerWidth,bannerHeight,window.frame.size.height);
bannerView_ = [[GADBannerView alloc] initWithAdSize:kGADAdSizeBanner origin:CGPointMake( 0 , 0)];
bannerView_.delegate = self;
bannerView_.adUnitID = @"ca-app-pub-8707318716621254/7164825544";
// 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 = viewController;
[viewController.view addSubview:bannerView_];
adRequest = [self request];
[bannerView_ loadRequest:adRequest];
It’s works for me.
But I want to hide the banner ad in some parts of my game, like I do it in android platform.
I try everything that I could find to remove the bannerView_ from admob, but none of them work
[bannerView_ removeFromSuperview];
[bannerView_ setDelegate:nil];
[bannerView_ release];
bannerView_ = nil;
[viewController.view setHidden:YES];
I think it’s because I add admob banner as a subview, but I have no idea how to make this work.
Any help will be appreciated.