-2

On iOS 7.x (only), When I call [self performSegueWithIdentifier:@"MySegue"], while self is a UINavigationController, I get the following NSGenericException:

Could not find a navigation controller for segue 'MySegue'. Push segues can only be used when the source controller is managed by an instance of UINavigationController.

Oddly enough, on iOS 8.x it works perfectly!

Every solution I saw regarding this exception tells you to embed the source view controller inside a UINavigationController, however in my case self is already a UINavigationController by itself.

It makes sense that performSegueWithIdentifier: would work when called on UINavigationController, and it does on iOS 8, so what's the problem on iOS 7??

Community
  • 1
  • 1
mllm
  • 17,068
  • 15
  • 53
  • 64

1 Answers1

0

Very first reaction - How did you manage to create a segue from a UINavigationController??? In Storyboard you can create a relationship from UINavigationController, not a segue!

Well, I am amazed if it is working on iOS 8. But conceptually you cannot ask UINavigationController to performSegueWithIdentifier as a segue with push is just a graphical way of asking the sourceViewController to push segue's destinationViewController.

In this case, how are you trying to tell a UINavigationController to perform a segue? It does not have a navigationController, it itself is!!!

So I guess if it works on iOS 7 its a bug there.

What you should be doing :

Either perform the selector -performSegueWithIdentifier on the controller which is the source of the segue.

OR

Ask the UINavigationController to push your destinationViewController.

Mayur Deshmukh
  • 1,169
  • 10
  • 25