6

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!

rmaddy
  • 314,917
  • 42
  • 532
  • 579
Idris
  • 1,658
  • 4
  • 16
  • 21

4 Answers4

19

Try

self.navigationController?.popViewControllerAnimated(true)

Update: Swift 4.2

self.navigationController?.popViewController(animated: true)
user3687284
  • 2,206
  • 1
  • 15
  • 14
1

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

Cal
  • 422
  • 6
  • 20
ciccioska
  • 1,291
  • 16
  • 22
1

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

self.dismiss(animated: true, completion: nil) 
Cal
  • 422
  • 6
  • 20
thanyaj
  • 302
  • 1
  • 6
-1
//hide the navigation bar on this page
override func viewWillAppear(_ animated: Bool) {
    self.navigationController?.isNavigationBarHidden = true
}

This will hide the navigation bar on your home page, but make sure you use viewWillAppear so whenever you come back to a page the navigation will not reappear.