0

I have a segue between two navigationControllers:

enter image description here

How can i "catch" the segue in prepareForSegue in one of the ViewControllers in the NavigationControllers ViewController-stack?

Lord Vermillion
  • 5,264
  • 20
  • 69
  • 109
  • Please check this url http://stackoverflow.com/questions/14307316/how-can-i-pass-value-between-navigationcontroller-and-viewcontroller-with-storyb – Rohit suvagiya Sep 29 '15 at 14:00
  • What do you mean by "catch" the segue? – Caleb Kleveter Sep 29 '15 at 14:11
  • prepareForSegue is not called in the ViewController when i perform a navigationController.performSegue – Lord Vermillion Sep 29 '15 at 14:14
  • What are you even trying to achieve? A navigationcontroller should not push another navigationcontroller. Or are you using relationship segues? They are eachothers root-viewcontrollers? What is this?! – ullstrm Sep 29 '15 at 14:20
  • I want to have 2 separate NavigationControllers, both NavigationControllers should be able to display a new instance of the other NavigationController with a display-modally segue. This might not be a good way to do it. – Lord Vermillion Sep 29 '15 at 14:29

1 Answers1

2

Navigation Controllers don't act as traditional view controllers.

How I would implement what you're asking is below, but I would first ask you: Why do you have two navigation controllers linking to eachother?

This is a very nontraditional use of navigation controllers. Navigation controllers simply control your navigation stack. They don't present any information to the user. My guess is if we looked at what you're trying to accomplish, this setup wouldn't be your best option.

That said, if you absolutely must accomplish something in the way you said above, here's how you could do it:

  1. If you'd like to use 'prepareForSegue' I would add a ViewController in the middle of the two navigation controllers.
  2. Then I would turn the alpha down to 0.0 for the ViewController
  3. In 'viewDidLoad' I would add the logic for seguing to either 'NavigationController' so that when you segue from one navigation controller it would hit the ViewController and immediately segue to the next navigation controller. Turning the alpha down to 0.0 would mean you wouldn't see the viewController (in theory, depending on your navigation stack).
  4. Then I'd add my setup to 'prepareForSegue'in the ViewController
Rob Norback
  • 6,401
  • 2
  • 34
  • 38
  • Not sure if this answered your question @lordvermillion , but if it has can you please accept it? Or let me know what more you need – Rob Norback Sep 29 '15 at 19:17