Closed mityakoval closed 7 years ago
In general you shouldn't be hiding the back button manually. If you have two items in the navigation stack, and replace the top one, you should still be able to go back. I would treat log out as a special case where you replace the entire navigation stack or even the rootViewController, since most likely the previous items in the stack are no longer valid.
A simplified example:
if logOut {
let mainViewController = MainViewController() // Whatever your initial controller is
navigationController.viewControllers = [mainViewController]
// or
window.rootViewController = UINavigationController(rootViewController: mainViewController)
} else {
// Do normal replace
}
@zachwaugh Thank you, I will try it out.
@zachwaugh I realize this is a really old ticket, but I am also curious about this. In my app I have a lot of different areas/features, that are (mostly) only accessible from a top-level navigation. I would love, when click one of those top level menu items, to reset the history state. Sort of like how Basecamp does this right now in the bottom nav (home, hey!, activity, etc).
Just to confirm, are you saying that this can only be done in iOS, by using different controllers?
I am trying to set the 'replace' action for authentication flow, so the user is not provided with the back-navigation button when logs in or out. I don't know why I assumed it would do that. Obviously, it did not, so I tried to set
navigationController.navigationItem.setHidesBackButton(true, animated: false)
manually for 'replace' but it does not work as well and the button is still there. I wonder if Turbolinks rewrites it somehow or I am doing something wrong?