我在目标 c 中有一个 iPhone 游戏应用程序,它使用私有类以编程方式加载每个视图。(不使用 nib 文件)我试图在视图中放置一个 admob 广告,但似乎我无法让它工作。我试图将我的 admob 广告视图放在 init 方法中,但它仍然没有加载视图。
以下是我如何初始化数据以加载视图的一些代码:
-(id)init
{
if( (self=[super init]))
{
played_ = NO;
KWSprite* background = [KWSprite spriteWithFile:@"title_background.png"];
background.position = ccp(winSize_.width/2, winSize_.height/2);
KWSprite* logo = [KWSprite spriteWithFile:@"logo.png"];
logo.position = ccp(winSize_.width/2, 260);
CCMenuItemImage* start = [CCMenuItemImage itemFromNormalImage:@"start.png" selectedImage:@"start_selected.png" target:self selector:@selector(pressStartButton:)]
CCMenuItemImage* credit = [CCMenuItemImage itemFromNormalImage:@"credit.png" selectedImage:@"credit_selected.png" target:self selector:@selector(pressCreditButton:)];
CCMenuItemImage* iADButton = [CCMenuItemImage itemFromNormalImage:@"noAdsD.png" selectedImage:@"noAdsD@2x.png" target:self selector:@selector(pressiAdButton:)];
CCMenuItemImage* howto = [CCMenuItemImage itemFromNormalImage:@"howto.png" selectedImage:@"howto_selected.png" target:self selector:@selector(pressHowtoButton:)];
CCMenu* menu = [CCMenu menuWithItems:howto, start, credit, iADButton, nil];
[menu alignItemsHorizontally];
menu.position = ccp(winSize_.width/2, 40);
[self addChild:background];
[self addChild:logo];
[self addChild:menu];
}
return self;
}