Cocos2d Admob集成 - 点击横幅不显示完整视图

时间:2011-08-18 02:58:07

标签: cocos2d-iphone admob

我正在尝试将AdMob集成到我的cocos2d游戏中,但我遇到了一些问题。基本上,广告会显示,但当我点击它时,横幅消失,整个视图都不显示。我正在使用google 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]];

}

谢谢你们

1 个答案:

答案 0 :(得分:0)

它在模拟器上不起作用,但它适用于设备,但如果你在横向模式下使用,你必须自己改造它。