NSGenericException', reason: 'Push segues can only be used when the source controller is managed by an instance of UINavigationController
Solution 1
add Navigation Controller to your initial view
- Select the initial view
- Go To Editor--> Embed In --> Navigation Controller.
Solution 2
In my case at the time the original VC performed the segue, the Navigation Controller was transitioning and already changed he visible VC.
I solved it by doing:
if (self.navigationController.visibleViewController == self) {
[self performSegueWithIdentifier:@"thankyou" sender:self];
}
no more crash. :)
Solution 3
Set UINavigationcontroller as Initial View controller (Initial Scene) in StoryBoard.
Solution 4
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.
Solution 5
in my particular case, the place to call into a subset of views that required a push was only from code and was not connectable via IB. The original project to create the subset of views was started with a dedicated button and thus was IB'able.
No segue was configurable, and thus any push resulted in this error.
My solution was simple: [self showViewController:targetViewController sender:self];
DouglasBoone
Updated on August 11, 2020Comments
-
DouglasBoone over 3 years
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