gpt4 book ai didi

ios - 使用 UiNavigationController 的好处

转载 作者:行者123 更新时间:2023-11-29 01:51:02 29 4
gpt4 key购买 nike

我正在开发一个 iOS 应用程序,我已经为 Android 开发了该应用程序。

问题是我不知道如何组织我的 UIViewControllers 考虑到我的应用程序页面的以下方案:

enter image description here

该方案很简单:有一个登录页面可通往主页。在这个主页上,有四个按钮都指向特定的 View 层次结构,但在每个按钮的最底部,用户将能够直接返回到主页。主页访问的每个页面还将有一个自定义后退按钮(我自己的图像)

问题是:在我的情况下使用 UINavigationController (显然以主页作为根)有什么好处吗?或者我可以简单地创建每个 Controller 并仅使用模态 Segues 吗?

最佳答案

  1. 如果您的 View Controller 具有导航关系,那么使用 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.

示例是真实世界:产品列表 => 产品详细信息 => 产品评论

  1. 如果你想临时呈现一个 View Controller ,主要焦点是你的 View Controller ,但你需要呈现另一个 View Controller 来执行诸如“过滤器”、“登录”、调整“设置”之类的任务,那么模态转场就是还有路要走

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.

  1. 如果您的 View Controller 彼此不相关,但每个 View Controller 都有自己的导航堆栈,那么 UITabBarController 是可行的方法

Storyboards (Xcode): What is the difference between a push and modal segue?

关于ios - 使用 UiNavigationController 的好处,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31414124/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com