Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between navigation controller and viewcontroller?

Difference between navigation controller and viewcontroller? I mean how can we decide when to use navigation controller or a normal view controller?

like image 354
saurabh Avatar asked Feb 26 '15 19:02

saurabh


Video Answer


1 Answers

Just my two cents:

A UIViewController represents a single view and you can put buttons in this view controller to segue to another UIViewController. If you want to segue back to the first UIViewController, you will have to worry about putting a button in the second view controller that leads back to the first. If you are drilling down into view controllers, this can be tedious having to remember to give the user a way back to a previous view controller.

A UINavigationController does a lot of this tedious work for you. As mentioned, it contains a stack of UIViewControllers. It will create a navigation bar at the top that will allow you to easily go back up the hierarchy of view controllers.

In short, if you have a hierarchy of view controllers that you want the user to easily navigate around, inbed your UIViewControllers into a UINavigation controller.

like image 103
Choppin Broccoli Avatar answered Sep 23 '22 21:09

Choppin Broccoli