Trying to wrap my head around how to structure an app around the UINavigationController. It seems to me that most explanations assume that the app always starts off at the root controller and drills down from there, but I'm unclear as to how this fits in with a login/registration step that happens before you get into the app. The structure will be like this:
Home page | Main app (typical nav hierarchy)
------------ |---------------------------------
Log in ----> Login page | App section 1
------------ | App section 2
Do login ------------------------> | etc.
<- Cancel |
|
Register -------------------> Register page |
----------------- |
Do registration ---> |
<- Cancel |
So basically I'm assuming that the "Main app" controller should actually be the root controller of the application, correct? In which case I'm unclear on how to handle the whole process that sits in front of it (which is basically like a nav structure separate from the app nav structure). Is the "Home page" a modal controller displayed over the main app, and also a separate nav controller for the login/register steps, so that it simply gets popped after login to put us back at the app root?
Hopefully I'm just overcomplicating what is really a simple thing, just hasn't seemed to click for me yet. Any pointers greatly appreciated.
EDIT: So here's what I ended up with, which seems to work for what I need. I have two UINavigationControllers, both assigned to the MainWindow in IB with separate starting NIBs. One is the app startup nav controller (home/login/registration) and the other is the main app nav controller. My app delegate has this code:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
[window addSubview:startNavController.view];
[window makeKeyAndVisible];
return YES;
}
- (void)activateMainApp {
[startNavController.view removeFromSuperview];
[window addSubview:appNavController.view];
[window makeKeyAndVisible];
}
In the last step of login/registration, I have this code that is what calls the app delegate to make the switch between nav controllers:
- (IBAction)continuePressed {
// Transfer control to the main app nav controller:
MyAppDelegate *app = (MyAppDelegate*)[[UIApplication sharedApplication] delegate];
[app activateMainApp];
[app release];
}
I suspect that I could have accomplished this with one nav controller, but this made logical sense to me based on my view structure and seems to work, and I end up with the main home view as the app nav controller's root view, as desired. Any additional feedback is appreciated if there's something bone-headed about this.