2011-08-18 66 views
0

我想将AdMob集成到我的cocos2d游戏中,并且遇到一些问题。基本上广告显示出来,但是当我点击它时,横幅消失,全视图不显示。我在google 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]]; 

} 

谢谢你们

+0

在稍后修改大小之前,告诉我CCLOG(@“%@”,NSStringFromCGSize(size))的输出。 –

回答

0

它不会在模拟器上工作,但它在设备上工作,但如果你是使用在风景模式下,你必须改变它自己。