views:

15

answers:

1

Hello, I have a number of viewControllers (iPad) that manage different views presenting various screens to the user (start screen -> settings screen -> main screen -> details screen -> summary screen). Those screens are being traversed sequentially (as arrows above indicate) based on user interaction.One exception to that rule is that I should be able to navigate to start screen from every other screen. I dont want to allow a user to explicitly navigate through those screens (using navigationbar) - only app logic should do that.

How should I handle such viewControllers presentation logic? Should i use NavigationController with navBar hidden and pop/push viewcontrollers on it? Or is it an unnecessary overkill? Maybe simply adding viewController.view to subviews of root view will be enough? Sorry if the question is silly but i think i still didint get MVC in iOS quite right

A: 

Yep, NavigationController is your friend in this type of scenario. The basics are:

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

...to add each subsequent view controller on to the stack, and ...

[self.navigationController popToRootViewControllerAnimated:YES];

...to get you back to the start screen.

And it is certainly possible to hide the navigationBar in your viewDidLoad method of each view controller, however this will prevent you from being able to go back in the stack. If that is intentional, then I think it's a perfectly valid set up.

Ben Scheirman