使用 UiNavigationController 的好处
Benefits from using UiNavigationController
我正在开发我已经为 Android 开发的 iOS 应用程序。
问题是考虑到我的应用程序页面的以下方案,我不知道如何组织我的 UIViewControllers:
方案很简单:有一个登录页面,该页面通向主页。在这个主页上,有四个按钮都指向特定的视图层次结构,但在每个按钮的最底部,用户将能够直接返回到主页。主页访问的每个页面也会有一个自定义的后退按钮(我自己的图片)
问题是:在我的案例中使用 UINavigationController
(显然以主页作为根)有什么好处吗?或者我可以简单地创建每个控制器并仅使用模态转场吗?
我想说的是,如果主 "home" 视图控制器中的每个附加视图控制器都没有任何子视图控制器,那么您可以让每个按钮以模态方式呈现一个视图控制器。
主要区别在于,如果您使用的是导航控制器,则可以 "pushing" 一个 vc 到视图控制器的导航堆栈上,而模态呈现它可以被认为是一个 "one time" 用户在新屏幕上做某事并且没有逻辑前进的地方(例如向新联系人添加信息)的操作。
您可以查看此post以获得更详细的答案:
What is the difference between Modal and Push segue in Storyboards?
- 如果您的视图控制器具有导航关系,那么使用 UINavigationController 是可行的方法:
In 'push' segue, you are basically pushing your ViewController into an
already setup "navigation stack". Well, of course, this is under the
assumption that the ViewController that performs the 'pushing'
operation belongs to the same navigation stack as the ViewController
is pushed into. Generally, you push a ViewController if the pushed
ViewController has some sort of a relationship with the pushing
ViewController. This is very common in applications that has a
NavigationController in its system. A good example for a push segue is
a system where you are displaying a list of contacts. And on tap of a
particular contact, you are pushing a VC that has the corresponding
details of the contact.
示例是真实世界:产品列表 => 产品详细信息 => 产品评论
- 如果您想临时呈现一个视图控制器并且主要焦点是您的视图控制器,但您需要呈现另一个视图控制器来执行 "filter" 、 "login" 等任务,请调整 "settings" 那么模态转场就是要走的路
In 'modal' segue, there is no stack as such. You are presenting a VC
'modally' over the presentee VC, if that makes sense. This can happen
across any ViewController without any relationship rules. The
presenter should take care of dismissing the VC it presented. A good
example for modal segue is login. On tap of login, you are modally
presenting a VC that has no relationship with the presenter.
- 如果您的视图控制器彼此不相关,但每个视图控制器都有自己的导航堆栈,那么
UITabBarController
是可行的方法
Storyboards (Xcode): What is the difference between a push and modal segue?
决定是使用模态转场还是显示(推送)完全取决于用户体验的目的和上下文。如果您引导用户沿着一条线性路径前进,其中每个连续的 VC 都深入到一个单一的想法中,那么请使用 Show segues 和 NavigationControllers。示例包括“设置”应用程序,您可以在其中深入了解所有细节。大多数电子商务应用程序将使用 NavigationController 来引导用户完成购买。
如果您想向用户展示一个概念,用户可以响应该概念,或者关闭它以继续使用该应用程序的其余部分。然后使用模式演示。在 iPhone 中添加联系人就是一个很好的例子。
在视觉上,不同之处在于 Show segue 从应用程序的右侧显示 VC,然后滑到前一个 VC。 (如果用户打开了阿拉伯语,从右到左的语言,Show segue 将来自 VC 的左侧)模态来自应用程序的底部。
通过查看您的绘图,但对您的应用程序一无所知,我认为您想要使用 NavigationControllers。您可能还想考虑使用 TabBarController。如果这些按钮中的每一个都引导用户以各种方式使用该应用程序,例如一个大应用程序中的迷你应用程序,那么 TabBarController 是合适的。
我正在开发我已经为 Android 开发的 iOS 应用程序。
问题是考虑到我的应用程序页面的以下方案,我不知道如何组织我的 UIViewControllers:
方案很简单:有一个登录页面,该页面通向主页。在这个主页上,有四个按钮都指向特定的视图层次结构,但在每个按钮的最底部,用户将能够直接返回到主页。主页访问的每个页面也会有一个自定义的后退按钮(我自己的图片)
问题是:在我的案例中使用 UINavigationController
(显然以主页作为根)有什么好处吗?或者我可以简单地创建每个控制器并仅使用模态转场吗?
我想说的是,如果主 "home" 视图控制器中的每个附加视图控制器都没有任何子视图控制器,那么您可以让每个按钮以模态方式呈现一个视图控制器。
主要区别在于,如果您使用的是导航控制器,则可以 "pushing" 一个 vc 到视图控制器的导航堆栈上,而模态呈现它可以被认为是一个 "one time" 用户在新屏幕上做某事并且没有逻辑前进的地方(例如向新联系人添加信息)的操作。
您可以查看此post以获得更详细的答案:
What is the difference between Modal and Push segue in Storyboards?
- 如果您的视图控制器具有导航关系,那么使用 UINavigationController 是可行的方法:
In 'push' segue, you are basically pushing your ViewController into an already setup "navigation stack". Well, of course, this is under the assumption that the ViewController that performs the 'pushing' operation belongs to the same navigation stack as the ViewController is pushed into. Generally, you push a ViewController if the pushed ViewController has some sort of a relationship with the pushing ViewController. This is very common in applications that has a NavigationController in its system. A good example for a push segue is a system where you are displaying a list of contacts. And on tap of a particular contact, you are pushing a VC that has the corresponding details of the contact.
示例是真实世界:产品列表 => 产品详细信息 => 产品评论
- 如果您想临时呈现一个视图控制器并且主要焦点是您的视图控制器,但您需要呈现另一个视图控制器来执行 "filter" 、 "login" 等任务,请调整 "settings" 那么模态转场就是要走的路
In 'modal' segue, there is no stack as such. You are presenting a VC 'modally' over the presentee VC, if that makes sense. This can happen across any ViewController without any relationship rules. The presenter should take care of dismissing the VC it presented. A good example for modal segue is login. On tap of login, you are modally presenting a VC that has no relationship with the presenter.
- 如果您的视图控制器彼此不相关,但每个视图控制器都有自己的导航堆栈,那么
UITabBarController
是可行的方法
Storyboards (Xcode): What is the difference between a push and modal segue?
决定是使用模态转场还是显示(推送)完全取决于用户体验的目的和上下文。如果您引导用户沿着一条线性路径前进,其中每个连续的 VC 都深入到一个单一的想法中,那么请使用 Show segues 和 NavigationControllers。示例包括“设置”应用程序,您可以在其中深入了解所有细节。大多数电子商务应用程序将使用 NavigationController 来引导用户完成购买。
如果您想向用户展示一个概念,用户可以响应该概念,或者关闭它以继续使用该应用程序的其余部分。然后使用模式演示。在 iPhone 中添加联系人就是一个很好的例子。
在视觉上,不同之处在于 Show segue 从应用程序的右侧显示 VC,然后滑到前一个 VC。 (如果用户打开了阿拉伯语,从右到左的语言,Show segue 将来自 VC 的左侧)模态来自应用程序的底部。
通过查看您的绘图,但对您的应用程序一无所知,我认为您想要使用 NavigationControllers。您可能还想考虑使用 TabBarController。如果这些按钮中的每一个都引导用户以各种方式使用该应用程序,例如一个大应用程序中的迷你应用程序,那么 TabBarController 是合适的。