【发布时间】:2011-08-18 02:58:06
【问题描述】:
我正在尝试将 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]];
}
谢谢大家
【问题讨论】:
-
在以后修改大小之前告诉我 CCLOG(@"%@", NSStringFromCGSize(size)) 输出什么。
标签: cocos2d-iphone admob