我的应用程序中有一个 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: "TabBarController") 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/