Search code examples
iosswiftxcodeuinavigationcontrollersegue

ViewController segue to Nav Controller Immediately Pops off Nav Controller and returns to ViewController


I have a View Controller embedded in a Nav Controller for use with AWS Cognito.

I then have a separate stack that's segued to from the initial VC.

I have the 2nd stack embedded in its own Nav Controller, and I've tried push, show, and present modally. Each time I attempt to segue to the new Nav Controller, the segue is performed, then the new stack pops off, and I'm presented with the initial VC. Here's how my storyboard is set up:

enter image description here

Here's my prepare for segue:

  override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
    if segue.identifier == "FindTruth" {
      if let findTruthVC = segue.destination as? FindTruth {
        if let user = sender as? User {
        if let userDetails = self.userDetails {
          user.userDetails = userDetails
          print("User Details: \(userDetails) passed")
        }
          findTruthVC.user = user
          print("User: \(user.userId) passed")
        }
      }
    }
  }

Calling the segue:

self.performSegue(withIdentifier: "FindTruth", sender: self.user)

There's no code nor storyboard reference from the 2nd stack to the initial stack/VC

Edit - When I set my storyboard as follows (with the segue from VC to VC) the view transitions, then the VC just goes blank, it doesn't transition back to the login View, but the app is unusable

enter image description here


Solution

  • Read this: ios - Navigation between multiple NavigationControllers