Search code examples
objective-ciphoneios7uinavigationcontrollerios8

iOS 7 NavigationController Segue Crash


I have a NavigationController as Initial View and a ViewController as the root view. From that root view i am trying to do a segue with:

[self.navigationController performSegueWithIdentifier:@"Segue" sender:self];

There´s another view controller in my storyboard and i gave the segue the correct identifier. On iOS 8 it works perfect, but on iOS 7 it crashes with the following message:

*** Terminating app due to uncaught exception 'NSGenericException', reason: 'Could not find a navigation controller for segue 'Segue'. Push segues can only be used when the source controller is managed by an instance of UINavigationController.'

I don´t get why it´s not working on iOS 7...

UPDATE: Here´s my Storyboard:

enter image description here


Solution

  • The problem is, that your segue has the UINavigationController as its source.

    A UINavigationController should not perform a segue. It should only be connected to a rootViewController, which may be a UIViewController (or its subclass). A segue should be performed from the rootViewController of the UINavigationController. The segue should have the rootViewController as its source and some other UIViewController (or its subclass) as its destination.

    Your screenshot shows that your UINavigationController is connected to a rootViewController. You now need to set the rootViewController as the source of the segue (having identifier Segue), which currently has your UINavigationController as its source. Now, from the rootViewController, call

    [self performSegueWithIndentifier:@"Segue" sender:nil]