Lucas Veiga
Lucas Veiga

Reputation: 1795

Pushing view from Modal View

im trying to push some view from my modal view. Im trying doing the same things that i do on other views. But the problem is, i think, thats the modalview doesnt have a navigation controller.

CadastroViewController *vaiCadastro = [[[CadastroViewController alloc] initWithNibName:
                                        NSStringFromClass([CadastroViewController class]) bundle:nil] autorelease];

[self.navigationController presentModalViewController:vaiCadastro animated:YES];

What can i do to push another view inside of my modal view?

Thanks!

Upvotes: 1

Views: 617

Answers (2)

Sudhanshu
Sudhanshu

Reputation: 3960

@Lucas Veiga you have to make the object of navigation controller in this case...and you will get the navigationBar the reason is modalview doesnt have a navigation controller

CadastroViewController *vaiCadastro = [[[CadastroViewController alloc] initWithNibName:
                                        NSStringFromClass([CadastroViewController class]) bundle:nil] autorelease];

    UINavigationController *navController = [[[UINavigationController alloc]
                                              initWithRootViewController:vaiCadastro] autorelease];

    [self.navigationController presentModalViewController:navController animated:YES];

Good luck!

Upvotes: 0

Di Wu
Di Wu

Reputation: 6448

"But the problem is, i think, thats the modalview doesnt have a navigation controller."

Yes, the modal view controller doesn't have a nav controller UNLESS you create one and add it to the modal view controller. Then it'll work.

Btw, you may wonder whether the modal view controller and its parent controller can share a nav controller or not, well, the answer is no, you need to create separate nav controllers for pushing-and-popping at different controller hierarchies.

Upvotes: 2

Related Questions