假设我有两个导航堆栈:一个用于注册和登录,另一个是我的主应用程序。
首次启动时,我将显示注册和登录堆栈,并在完成过渡到主应用程序堆栈时显示。如何在这两个堆栈之间平滑切换?
此外,我将显示主应用程序堆栈,并且仅在用户退出时才显示登录和注册堆栈,因此这一点更加清楚:在导航控制器上只有self.present
。
答案 0 :(得分:0)
您只需要将导航实例设置为
(UIApplication.shared.delegate as! AppDelegate).window!.rootViewController = // main or register stack
实际上,您不必使用2个堆栈,而是将1个堆栈适当地用于push / pop,但是在执行登录/ home转换时就可以使用
// this will clear all controllers from the stack and set only the assigned one
self.navigationController?.setViewControllers([mainVC/loginVC],animated:true)