I am building a new app. My auth flow presents a tab bar controller with 5 tabs at the end.
In my login screen, it presents the tab bar controller after successful login:
let vc = MainTabBarVC()
vc.modalPresentationStyle = .fullScreen
self?.present(vc, animated: true)
On the tab bar controller, inside the last tab (My Settings VC), there is a log-out button. How can I dismiss the tab bar entirely with this log-out button's action and return to the login screen? I am trying to dismiss the entire tab bar controller from inside one of its tab.
Solved:
Thanks to @Paul and @HangarRash for comments. As @Paul told me in the comments, I changed the root view controller, and it worked perfectly. My code:
let vc = LoginVC(authManager: authManager)
if let delegate = UIApplication.shared.connectedScenes.first?.delegate as? SceneDelegate {
guard let window = delegate.window else { return }
UIView.transition(with: window, duration: 0.3, options: .transitionCrossDissolve, animations: {
window.rootViewController = vc
window.makeKeyAndVisible()
}, completion: { completed in
// Something maybe later
})
}