Mateus
Mateus

Reputation: 2668

How to push NavigationController on Xcode 4.2?

With Xcode 4.1, I used to push a Navigation Controller using the following code:

-(IBAction)goClasse1:(id)sender{

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

}

But now I updated to Xcode 4.2, this code just doesn't work. Why? How can I fix it?

Upvotes: 1

Views: 3825

Answers (1)

SentineL
SentineL

Reputation: 4732

I always use it like this:

-(IBAction)goClasse1:(id)sender{

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

}

and you don't need to initialize or delegate navigation controller in all your view controllers: it is already initialized in ViewController class.

Upvotes: 4

Related Questions