我正在开发一个需要不断通过服务器进行身份验证的应用程序,因此我想保存用户凭据,然后在需要时使用它。因此,当用户启动应用程序时,将对凭据进行验证检查,如果有效,则将用户引导至 UITabBarController。这样用户就不必在每次执行应用程序时都登录。考虑到这一点,每当用户点击注销时,我都需要推送登录 View Controller 并关闭 UITabBarController。我的问题是我将如何解雇 UITabBarController?我认为委托(delegate)不会有帮助,因为我的登录 View Controller 甚至不知道 UITabBarController 并且我无法让 UITabBarController 自行解散。我还担心如果我不关闭 UITabBarController 它会保留在内存中。
我画了一张图表来阐明这个场景。
谢谢, 马科斯。
最佳答案
你有两个选择:
1)从标签栏 Controller 呈现登录 View Controller
[self.tabBarController presentViewController:loginViewController animated:YES];
2)每次更改应用程序窗口的 Root View Controller 时:
[[UIApplication sharedApplication].window setRootViewController:tabBarController];
然后:
[[UIApplication sharedApplication].window setRootViewController:loginViewController];
关于ios - 关闭 UITabBarController 并推送登录 View Controller ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17763972/