我有一个UIViewController与一个按钮。如何在swift中从我的UIViewController设置rootViewController?
此按钮有一个方法,应该切换到另一个UIViewController。以前我曾用它来处理:
self.performSegueWithIdentifier("moveToMainWindow", sender: self)
,但我想改变它的东西,如:
let sb = UIStoryboard(name: "Main", bundle: nil)
if let tabBarVC = sb.instantiateViewControllerWithIdentifier("MainWindow") as? TabController {
self.rootViewController = tabBarVC
}
但是这条线self.rootViewController = tabBarVC
带来错误类型的ViewController的值没有任何成员RootViewController的。
有什么我可以在这里修复,以便它可能工作?
我想避免做performSegueWithIdentifier
,因为后来我在做几次self.dismissViewControllerAnimated(true, completion: {})
,在这种情况下,我的MainWindow
面板也被解雇了。所以我想如果我在这里改变segue的类型,这个面板永远不会被隐藏。