如何在Xcode 4.2上推送NavigationController?

时间:2011-11-14 01:08:18

标签: ios iphone xcode

使用Xcode 4.1,我曾使用以下代码推送导航控制器:

-(IBAction)goClasse1:(id)sender{

        Classe1Chamada *goCL1 = [[Classe1Chamada alloc] initWithNibName:@"Classe1Chamada" bundle:[NSBundle mainBundle]];
    [[self navigationController] pushViewController:goCL1 animated:YES];
    [goCL1];

}

但是现在我更新到Xcode 4.2,这段代码不起作用。为什么?我该如何解决?

1 个答案:

答案 0 :(得分:4)

我总是这样使用它:

-(IBAction)goClasse1:(id)sender{

        Classe1Chamada *goCL1 = [[Classe1Chamada alloc] initWithNibName:@"Classe1Chamada" bundle:[NSBundle mainBundle]];
    [self.navigationController pushViewController:goCL1 animated:YES];
    [goCL1 release];

}

并且您不需要在所有视图控制器中初始化或委派导航控制器:它已在ViewController类中初始化。

相关问题