是否可以使用以下代码复制UITabBarController
的行为?
我要做的是让“抽屉菜单”作为UITabBarController
使用。每次按下任何菜单项时,该菜单项的选定VC将成为新的根VC
,导航堆栈将重置,使VC
成为堆栈中的第一个VC
。
dispatch_async(dispatch_get_main_queue(), { () -> Void in
let storyboard: UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
let AccountVc = storyboard.instantiateViewControllerWithIdentifier("AccountVc")
let navigationController = self.view.window?.rootViewController as! UINavigationController
//Remove both login scene and menu scene
self.presentingViewController!.presentingViewController!.dismissViewControllerAnimated(false) { () -> Void in
navigationController.setViewControllers([AccountVc], animated: false)
}
})
上述代码有效,在这种情况下,它会将MenuVC
与loginVC
一起删除,然后将导航设置AccountVC
重置为新根。
有没有更好的方法呢?