我的方法不会创建东西,但会创建NSLog

时间:2012-12-02 22:12:46

标签: iphone objective-c xcode

我的标题有点长,因为我不知道如何以最简单的方式描述我的问题。

在我的游戏中,我使用游戏中心,当玩家通过身份验证时我想要发生一些事情。

NSLog(@"Authentication changed: player authenticated."); 
    MenuViewController *menu=[[MenuViewController alloc] init];
    [menu doWhenAuthenticated];
    [menu release];

这是我想在menuViewController中运行的方法

-(void)doWhenAuthenticated{
    NSLog(@"doWhenAuthenticated");
    for (int i = 0; i < 3; i++){

    CGRect frame = CGRectMake(10, ((i*10)*10), 100, 30);
    UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    button.frame = frame;
    [button setTitle:(NSString *)@"new button" forState:UIControlStateNormal];
    [button addTarget:self action:@selector(buttonEvent:) forControlEvents:UIControlEventTouchUpInside];
    //[self.view addSubview:button];
    [scroller addSubview:button];
    }
}

我在设置一个也没有发生的label.text之前遇到了这个问题,上面代码中的这些按钮也没有被创建。然而NSLog @“doWhenAuthenticated”确实发生了,所以我不明白。

为什么会这样?

0 个答案:

没有答案