ios - View Controller 的最佳组织

标签 ios swift swift3

我正在用 Swift 3 编写一个 iOS 应用程序。 应用程序接收 5 种颜色的数组,每种颜色必须有自己的 ViewController。每次应用程序启动时,数组中颜色的顺序可能会有所不同。

当用户启动应用程序时,他们将看到一个开始屏幕。按下开始按钮后,它们将被定向到数组中第一种颜色的 ViewController。从那里,他们将能够按前进和后退按钮来浏览颜色数组,如果在第一种颜色上按后退,则可以返回到开始屏幕。

排列和链接 ViewController 的最佳方式是什么? 如果可能的话,我更愿意使用 UINavigationController。 谢谢。

最佳答案

像这样的事情我会以编程方式完成。使用 UINavigationController,您将在顶部始终有一个带有“后退”按钮的栏。当然,您可以隐藏它,但不需要导航 Controller 。

只需创建您的 5 个 Controller ,然后根据数组中的索引,呈现您的 VC。

let vc = ClassOfYourVC() //change this to your class name
self.presentViewController(vc, animated: true, completion: nil)

关于ios - View Controller 的最佳组织,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40349641/

相关文章:

ios - 如何从不同的 ViewController 执行 collectionView 类

ios - 滚动时隐藏状态栏

ios - NSStreams-code 仅在调试器模式下按预期工作

ios - 没有参数的Swift中的返回函数类型

ios - UITableView 在每个部分返回相同的项目

ios - Swift:将 String 转换为 Float 并在进行一些数学运算后再次返回 String

swift - 如何记录 didReceiveRemoteNotification userInfo? - swift

ios - swift : cannot subscript a value of type [Dictionary<String, AnyObject>] 具有字符串类型的索引

ios - 通过 Azure 的 Google 登录错误

ios - 嵌套 UICollectionView 的问题