Can't dismiss navigation controller in Swift

10,218

Solution 1

Try

self.navigationController?.popViewControllerAnimated(true)

Update: Swift 4.2

self.navigationController?.popViewController(animated: true)

Solution 2

Is a signup view controller being presented Modally? Then, on sign up view controller, you could do

self.dismiss(animated: true, completion: nil) 

Solution 3

Try to use a ViewController only for the LoginView. Then use self.dismiss with PerformSegue to reach the NavigationController.

Share:
10,218
Idris
Author by

Idris

Updated on June 30, 2022

Comments

  • Idris
    Idris almost 2 years

    So I have a simple navigation controller with a sign up, hit done and you go to the home page. The problem is when you go to the home page, the navigation controller follows.

    enter image description here

    enter image description here

    As you can see in the last picture (home page), the navigation bar remains. When the user presses "Done" on the first image I use self.performSegueWithIdentifier("loginTrue", sender: nil) to go to the "home page". I've tried using

    self.presentingViewController?.dismissViewControllerAnimated(true, completion: nil)
    

    But nothing seems to happen. So to wrap it all up, any idea on how I can "dismiss" the navigation controller from the "home page"? Thanks!