ios - 从 TableView 转到导航 Controller 前面的 View

标签 ios xcode swift segue

在我的项目中,我在 TableView 中有一个带有 3 个选项的幻灯片菜单。根据所选的选项,我想转到 ViewController1、ViewController2 或 ViewController3,它们前面都有一个导航 Controller 。

目前,我在 Storyboard 中使用从原型(prototype)单元格到 ViewController1 的转场,使用“segueid”作为标识符,因此所有选项都转场到 ViewController1。

那是 file.swift 中准备转场的代码:

override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
    if segue.identifier == "segueid"{
        var DestViewController = segue.destinationViewController as! UINavigationController}}

当 XCode 只允许我从 Storyboard 中的单元格设置一个 segue 时,问题就来了,所以我无法指向 VC2 和 VC3。

有什么方法可以根据从 TableView 中选择的行来切换到导航 Controller 前面的不同 View ?

最佳答案

您应该在 View Controller 之间创建转场。

不要创建从单元格到 View Controller 的转场。

然后在您选择一个单元格之后,您应该决定要调用哪个 segue。

关于ios - 从 TableView 转到导航 Controller 前面的 View ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35232018/

相关文章:

swift - 当变量首次用于其自身初始化时,如何清除 "Variable ... used before being initialized"错误?

swift - UILabel 中使用 NSAttributedString 的 HTML 文本(带表格)

iOS 框架 XLPagerTabStrip 无法正常工作

xcode - 显式将基础 SDK 设置为 3.2 以捕获编译器错误

iOS 6 vs 7 外观build设置

ios - self.navigationController 分配为 RootViewController 后为空?

objective-c - 从多个 ImageView 中识别特定 ImageView

ios新创建的swift文件在xcode中默认导入cocoa

Javascript在浏览器中运行,而不是在带有cordova的phonegap应用程序中运行

ios - 如何在 Swift 中使用另一个数组中的元素过滤数组?