In my app I have BaseViewController (NavigationController) as the root controller. I normally use the following code to navigate:
[self.navigationController pushViewController:childController animated:YES];
But on one of the actions I want the next view to animate buttom to top, so I use:
[self presentModalViewController:childController animated:YES];
Everything works so far. In the modal view I then want to push another controller, but this doesn't seem to work. I have tried the following:
// self.navigationController is null, so this doesn't work
[self.navigationController pushViewController:childController animated:YES];
// self.parentViewController is the BaseViewController and not null, but this
// won't work either. This also generates a warning "UIViewController' may not
// respond to '-pushViewController:animated:"
[self.parentViewController pushViewController:childController animated:YES];
In both cases nothing happens. Is pushViewController disabled while a modal view is still showing? If so, is there another way I can:
?
VC3 -> present VC2 -> VC1 VC2 needs to be in a UINavigationController then after you present it you can push VC3. The back button will work as expected on VC3, for VC2 you should call dismiss when the back button is pressed. Try implementing some of that in code and then update your question.
If you presentModelViewController then you need to dismiss it before you can call the navigation controller's methods, otherwise you have to put this view controller into the navigation stack in order to put another view controller on top of it.
Use the following lines of code to present childController, then navigationcontroller will not be null so it will work as u want.
UINavigationController * childNavigationController = [[UINavigationController alloc] initWithRootViewController:childController];
childNavigationController.navigationBarHidden = YES;//if u want to show navigation bar then remove this line
[self.navigationController presentModalViewController:coinsNavigationController animated:YES];
After presentModelViewController you can present or push any other view controller within presented view controller.
// self.navigationController in this case will never be null. so following line will work perfectly inside presented child View controller (childController)
[self.navigationController pushViewController:childController animated:YES];
Here is the desired output:
Hope this will be useful and easy solution.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With