假设我有两个导航堆栈:一个用于注册和登录,另一个是我的主应用程序。
在首次启动时,我将显示注册和登录堆栈以及完成时到主应用程序堆栈的转换。如何在这两个堆栈之间平滑切换?
此外,我将显示主应用程序堆栈,并且仅在用户退出时显示登录和注册堆栈,因此这一点更清晰:导航 Controller 上只有一个 self.present
.
最佳答案
您只需将导航实例设置为
(UIApplication.shared.delegate as! AppDelegate).window!.rootViewController = // main or register stack
实际上,您不必使用 2 个堆栈,而是使用 1 个堆栈,并适本地将其用于推送/弹出,但在进行登录/主页转换时需要这样做
// this will clear all controllers from the stack and set only the assigned one
self.navigationController?.setViewControllers([mainVC/loginVC],animated:true)
关于ios - 在两个 UINavigationController 之间切换,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55271085/