ios - Swift-从 ViewController 转到 UITabBarController 页面

标签 ios iphone swift xcode uitabbarcontroller

我的应用程序中有一个 UITabViewController。在 UITabViewController 的第三个 ViewController 上,用户可以转到 UITabViewController 之外的单独的 ViewController 。但是,当他们返回时,UITabView 栏不会显示。因此,我转回了 UITabViewController,但现在它只是转到 UITabViewController 的第一页,而不是第三页。我在单独的 ViewController 文件上有一个prepareForSegue(),告诉它转到第三页,但它似乎不起作用。这是我的代码:

func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
    if(segue.identifier == "tabBarShow"){
        if let tabVC = segue.destination as? UITabBarController {
            tabVC.selectedIndex = 2
            let tabBarController = storyboard?.instantiateViewController(withIdentifier: "TabBarC‌​ontroller") as! UITabBarController
            tabBarController.selectedViewController = tabBarController.viewControllers![2]
        }
    }
}

有谁知道怎么解决这个问题吗?任何帮助将不胜感激。非常感谢!

干杯,西奥

最佳答案

你尝试过吗:

@IBAction func backTouched(sender: AnyObject) {
        dismissViewControllerAnimated(true, completion: nil)
}

将其链接到您想要关闭的 Controller 中?或者使用 func unWindToSegue(segue: ...) 方法?

关于ios - Swift-从 ViewController 转到 UITabBarController 页面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43530966/

相关文章:

ios - Marvel api 快速返回哈希值、时间戳和键组合无效

iphone - Obj-C,仅在 iOS5 可用时有条件地运行代码?

SWIFT:仅获取路径

ios - 共享扩展到即将到来的主机应用程序断点在 swift 中不起作用

ios - Adobe RM SDK 注释

ios - Realm Exception - 更新 Realm 对象,持久化与否

iphone - 执行错误访问问题

ios - 有什么方法可以在 appdelegate 中为项目中的所有 UIImage 属性使用 `UIImageRenderingModeAlwaysOriginal`

ios - 如何在 swift 4 中对字典数组进行排序

swift - 警告 "the app icon has (x) unassigned children "和 x 不断增加