繁体   English   中英

Swift-从ViewController Segue到UITabBarController页面

[英]Swift- Segue to UITabBarController page from ViewController

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

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)
}

将其链接到您要关闭的控制器中? 还是使用func unWindToSegue(segue:...)方法?

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM