I have 3 viewcontroller/views at the root of my Application: LoginViewController, HomeViewController, and PlayViewcontroller
What I'm looking for is a good way to swap between these three based on state (eg: successfully logging in would result in the loginViewcontroller pinging its delegate [the rootviewcontroller] to remove itself and display the homeviewcontroller)
I seem to have a couple options here:
1.RootViewController is a UIViewController. It adds/removes subviews as needed.
[self.view addSubview:loginViewController.view];
2.RootViewController is a UIViewController. It presents/removes views modally as needed.
[self presentViewController:loginViewcontroller animated:NO completion:nil];
3.RootViewController is a UINavigationController. It pushes/pops stuff.
[self pushViewcontroller:loginViewController];
I have read that the first option is kinda working around the whole idea of what a viewcontroller is supposed to be, and therefore not ideal.
The second option seems odd because my entire application is a modal? Can viewcontrollers be modally presented on top of modally presented viewcontrollers?
The third option seems best, (as stated here), but it runs into a few problems with my specific implementation:
- the metaphor for the "navigationController" doesn't exactly fit (I'm not "drilling down into the home controller" by logging in...)
- Do I constantly switch out the navController's rootviewcontroller? Or do I just push playvc on top of homevc on top of loginvc?
- LoginVC is a navigationViewController in itself- it pushes on vc's that go through the multi-step process of creating an account, and I can't push navcontrollers on navcontrollers.
So, my question is this:
What is the best way to architect view controllers at equal level of hierarchy when some of them are UINavigationControllers themselves?
****Note:*** I have already looked here, but it didn't give sufficent answers for my use case (multiple navcontrollers).*******
EDIT: I've found an answer: I'm thinking of the problem wrong, and should instead be thinking in terms of creating my own Container ViewController.