Reputation: 2466
I have my viewControllers like this:
startViewController ------> menuViewController
\
\ ------> ImportantViewController
From startMenu
I pushed menuView
then I pushed again importantView
, on that I have made importantView
as my rootViewcontroller for it to become my parent view like as below:
UINavigationController *navControl = [[UINavigationController alloc] initWithRootViewController: vc];
[self presentModalViewController: navControl animated: YES];
From that I pushed view after importantView
via:
[self.navigationController pushViewController:vc animated:YES];
Now my prob is like this:
ImportantVIew
as my rootView
pushed to menuView
pushed to ViewA
then pushed to View B then option whether to return to menuView
or return to ViewA
.
My question is:
I want to make my ViewB
as a rootView, then when I go to ImportantView
it will then return it to as rootView
. Is it possible to have 2 rootView? Or I need to just replace each other?
Help would be much appreciated. Thanks.
Upvotes: 0
Views: 1804
Reputation: 14068
What is the reason for changing the root view controller all the time?
With viewA and viewB calling in circle you would build up an endless stack of view controllers. That is probably not what you want to do.
Take a step back and re-think what you are trying to achive. Do you just want to change between viewA and viewB? In that case you sould go for a different architecture/pattern than the usual pushViewController thing. Read a bit about removeFromParentViewController or transitionFromViewController:toViewController:. Or get familiar with manipulating the chain of view controllers yourself. Those things might help achieving the user experience that you want to create without building up an endless stack of view controllers.
Upvotes: 1