Cocos2d iphone Cocos2d Admob集成-单击横幅';看不到全景

Cocos2d iphone Cocos2d Admob集成-单击横幅';看不到全景,cocos2d-iphone,admob,Cocos2d Iphone,Admob,我试图将AdMob集成到我的cocos2d游戏中,但我遇到了一些问题。基本上,广告会显示出来,但当我点击它时,横幅消失了,完整视图也没有显示出来。我使用的是谷歌admob页面上的代码的一个稍加修改的版本。这是我的密码: -(void) addAdMobBanner{ NSLog(@"adding Admob"); controller = [[RootViewController alloc]init]; CGSize size = [[CCDirector sharedDirector] wi

我试图将AdMob集成到我的cocos2d游戏中,但我遇到了一些问题。基本上,广告会显示出来,但当我点击它时,横幅消失了,完整视图也没有显示出来。我使用的是谷歌admob页面上的代码的一个稍加修改的版本。这是我的密码:

-(void) addAdMobBanner{
NSLog(@"adding Admob");
controller = [[RootViewController alloc]init];
CGSize size = [[CCDirector sharedDirector] winSize];
controller.view.frame = CGRectMake(0,0,size.width,size.height);
// Create a view of the standard size at the bottom of the screen.
bannerView = [[GADBannerView alloc]
initWithFrame:CGRectMake(size.width/2+50,
size.height-GAD_SIZE_468x60.height,
GAD_SIZE_468x60.width,
GAD_SIZE_468x60.height)];

// Specify the ad's "unit identifier." This is your AdMob Publisher ID.
bannerView.adUnitID = @"xxxxxxxxxxxx";

// 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 = controller;

[controller.view addSubview:bannerView];
[[[CCDirector sharedDirector] openGLView]addSubview : controller.view];
[bannerView loadRequest:[GADRequest request]];

}

谢谢大家

它在模拟器上不起作用,但在设备上起作用,但是如果你在横向模式下使用,你必须自己转换它。

在你以后修改大小之前,告诉我CCLOG(@“%@”,NSStringFromCGSize(size))输出了什么。