0
votes

I have 3 viewcontrollers the second one is added to the first using viewcontroller1.m :

[self presentModalViewController:vc2 animated:YES];    
vc2.view.superview.frame = CGRectMake(50, 740, 695, 245);

now I want to navigate from the second to my third viewcontroller , I used in my viewcontroller2.m :

[self.navigationController pushViewController:vc3 animated:YES]; 

but didn't work. This is what I want to do : viewcontroller1-->viewcontroller2(navigate and pass an object to viewcontroller3)-->viewcontroller3

1
Why are you using presentModalViewController: ? - Wain
my second viewcontroller should be a modal view , that I added it to my first viewcontroller - Ouassim Mouyarden
Are you wanting to use a navigation controller for the views you will display in the modal view? - Jason Barker
I want to dissmiss the modal view and then navigate to my third viewcontroller - Ouassim Mouyarden

1 Answers

1
votes

View controllers do not normally bring an UINavigationController by default. When you are presenting a modal view controller, you are losing that source's navigation controller. You can create a new navigation controller, associate it with vc2, and present that modal view controller modally. something like:

UINavigationController *controller=[[UINavigationController alloc] initWithRootViewController:vc2];
[self presentModalViewController:controller animated:YES];