User1238 User1238 - 1 year ago 63
Swift Question

Delete an action from the NavigationBar

I have 3 views with 3 controllers:

HomeView -> LoginView -> AccountView

In HomeView I added a NavigationBarController. When the user login in the LoginView, he is moved to the AccountView. When He clicks on the back button in the NavigationBar he is sent to the loginView and this is the problem. After logging if the user click on the back button I want to show him the HomeView and not the LoginView. I tried this code but it take some time to be executed and I can see the LoginView for some ms.

override func viewWillAppear(animated: Bool) {

if let token = userDefaults.valueForKey("token") {//User logged in
self.performSegueWithIdentifier("homeSegue", sender: self)

Is there another way to di it?

ddb ddb
Answer Source

at the viewDidApper in the AccountView, you can delete the LoginView from the ViewControllers stack this way


this way, if user will go back, he/she will see the home page as requested