导航控制器和ViewController之间的区别?

问题描述:

导航控制器和视图控制器之间的区别?
我的意思是我们该如何决定何时使用导航控制器或普通视图控制器?

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

仅需两美分:

UIViewController表示单个视图,您可以在此视图控制器中放置按钮以选择另一个UIViewController。如果您想回到第一个UIViewController,则将不得不担心在第二个视图控制器中放置一个按钮,该按钮会返回到第一个。如果您要深入研究视图控制器,那么必须记住要给用户一种返回到以前的视图控制器的方式,可能会很繁琐。

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.

UINavigationController会做很多事情这项繁琐的工作为您服务。如前所述,它包含一堆UIViewControllers。它将在顶部创建一个导航栏,使您可以轻松地返回视图控制器的层次结构。

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.

简而言之,如果您具有视图控制器的层次结构您希望用户轻松浏览,将您的UIViewControllers嵌入到UINavigation控制器中。

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.