ios - 关闭 UITabBarController 并推送登录 View Controller

标签 ios uiviewcontroller uitabbarcontroller

我正在开发一个需要不断通过服务器进行身份验证的应用程序,因此我想保存用户凭据,然后在需要时使用它。因此,当用户启动应用程序时,将对凭据进行验证检查,如果有效,则将用户引导至 UITabBarController。这样用户就不必在每次执行应用程序时都登录。考虑到这一点,每当用户点击注销时,我都需要推送登录 View Controller 并关闭 UITabBarController。我的问题是我将如何解雇 UITabBarController?我认为委托(delegate)不会有帮助,因为我的登录 View Controller 甚至不知道 UITabBarController 并且我无法让 UITabBarController 自行解散。我还担心如果我不关闭 UITabBarController 它会保留在内存中。

我画了一张图表来阐明这个场景。

enter image description here

谢谢, 马科斯。

最佳答案

你有两个选择:

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/

相关文章:

ios - DetailViewController 上的 TabBar Controller

iphone - 在 TabBarController 中的选项卡之间切换/导航

ios - 检查 UIScrollView 是否到达顶部或底部

iOS - 并发访问内存资源

ios - 调用 topLayoutGuide 会完全中断滚动吗?

ios - 移动到另一个导航 Controller 时,后退按钮变得无响应

ios - 切换标签时如何将UITabbarItem的viewcontroller设置为默认viewcontroller?

ios - 线程 1 : EXC_BAD_ACCESS when accessing custom view attribute

ios - Swift - 如何从 ModalPopupController 重新加载 ViewController

ios - 如何快速更新实例变量?