From the documentation:
The UINavigationController class implements a specialized view controller that manages the navigation of hierarchical content. This navigation interface makes it possible to present your data efficiently and makes it easier for the user to navigate that content. You generally use this class as-is but you may also subclass to customize the class behavior.
To pop back to the previous page you can do this:
To pop to the root of the navigation stack, you can do this:
In your storyboard select the ViewController that you want to embed into a Navigation Controller.
Then navigate to Editor > Embed In > Navigation Controller
And that will create your navigation controller
//Swift let viewController = UIViewController() let navigationController = UINavigationController(rootViewController: viewController) //Objective-C UIViewController *viewController = [[UIViewController alloc] init]; UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:viewController];
//Swift let fooViewController = UIViewController() navigationController?.pushViewController(fooViewController, animated: true) //Objective-C UIViewController *fooViewController = [[UIViewController alloc] init]; [navigationController pushViewController:fooViewController animated:YES];
UINavigationController is used to form a tree-like hierarchy of view controllers, which is known as a
From developers perspective:
You can connect independently made controller and get all the benefits of a free hierarchy manager and common UI presenter gratis.
UINavigationController animates the transition to new controllers and provides the back functionality for you automatically.
UINavigationControlleralso gives access to all the other controllers in the
navigation stack which can help access to some functionality or data.
From user's perspective:
UINavigationController helps to remember where user is at the moment (navigation bar title) and how he can go back (embedded back button) to one of the previous screens.