NSGenericException', reason: 'Push segues can only be used when the source controller is managed by an instance of UINavigationController-Collection of common programming errors
so I’m making an app with 5 view controllers, the first is embedded in a UINavigationController and the segue between the first 4 view controllers works fine. However introducing a 5th View Controller has broken this, and I’m getting the error
Terminating app due to uncaught exception 'NSGenericException', reason: 'Push segues can only be used when the source controller is managed by an instance of UINavigationController.'
I havent done anything differently with this 5th view controller, its just a standard ViewController with an image view and a label, and all of my segues are called by ctrl dragging buttons in the storyboard. Does anybody have any idea whats causing this?
Thanks
-
add Navigation Controller to your initial view
- Select the initial view
- Go To Editor–> Embed In –> Navigation Controller.
-
Set UINavigationcontroller as Initial View controller (Initial Scene) in StoryBoard.
-
This is most likely because your push segue from the button or whatever is pointing to a view controller not the navigation view controller your view controller inherits. So, you have to point the segue to the navigation controller.
Hope this helps.
-
Try use a modal instead of a push segue.
-
You just need to embed a Navigation Controller into your Source View Controller ( The one initial view, not the view you are pushing for ) . This can be done by selecting the Source View Controller and Go To Editor–> Embed In –> Navigation Controller.
If you think that the Navigation Bar that the Navigation Controller has done . Simply select the Navigation Controller , In the “Show the Attributes Inspector” disable the Shows Navigation Bar.
-
If your application has navigation controller as root view controller of window ,select storyboard file and then select the corresponding navigation controller , in Simulated Metrics select Is Initial View Controller checkbox. This worked for me. Hope this helps.
Originally posted 2013-12-02 06:14:21.