NSGenericException', reason: 'Push segues can only be used when the source controller is managed by an instance of UINavigationController

IphoneIosUinavigationcontrollerSegue

Iphone Problem Overview


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

Iphone Solutions


Solution 1 - Iphone

add Navigation Controller to your initial view

  1. Select the initial view
  2. Go To Editor--> Embed In --> Navigation Controller.

Solution 2 - Iphone

Set UINavigationcontroller as Initial View controller (Initial Scene) in StoryBoard.

Solution 3 - Iphone

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 4 - Iphone

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 - Iphone

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.

Solution 6 - Iphone

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];

Solution 7 - Iphone

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.

Solution 8 - Iphone

I have faced same problem after few minutes I could solve it.

I have deleted segue connections and I have made connections again from one view to other views.That's it the problem is solved. the thing is I have deleted views and I have made few changes to the views in story board scene. And important thing is you need to check connections working properly from one view to another view.

This may be helpful to some one I hope....

Solution 9 - Iphone

I have faced same problem and I searched a lot but nothing could help me. I tried in many ways.Finally I found solution. I am doing a project in xcode 5 and developed views using story board. I have 3 screens and my connections are..

view1 to view2-->push

view2 to view3-->push

view2 to view1-->modal(this is my mistake we need to use push only)

this is fine working well but I have placed bar button item(Back) in view2 and segue connection was modal . when I click on view2 bar button it is redirected to view1 properly but when I try to go ahead from view1 to view2 I got the same error. Because if you give push segue type from source view to destination view you need to use same push segue from destination view to source view..

I hope it will be helpful to someone..thanks

Solution 10 - Iphone

I had the same problem as you had.

My problem was that I was calling the identifier of a segue that wasn't accessible from within the class I was calling the segue from. I solved it by adding another segue directly to the view from the ViewController that had access to the class I was working in. Hope this helps.

Solution 11 - Iphone

if you are using UIViewController class

then check one thing in the declaration of segue identifier for example, you have set

Identifier:MySegue1 Segue:Present Modally (choose this if you are using UIViewController Class)

Presentation: Default Transition: Default

and check one more thing that your object deceleration is correct

Maybe my answer is not exactly correct,but this is what all i get to know abut this error. hope it will help you lil bit.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionDouglasBooneView Question on Stackoverflow
Solution 1 - IphoneKirit VaghelaView Answer on Stackoverflow
Solution 2 - IphoneVinayView Answer on Stackoverflow
Solution 3 - IphoneGaston MorixeView Answer on Stackoverflow
Solution 4 - IphoneYosep KimView Answer on Stackoverflow
Solution 5 - IphoneNicholas ChewView Answer on Stackoverflow
Solution 6 - Iphonedrew..View Answer on Stackoverflow
Solution 7 - IphoneSinghView Answer on Stackoverflow
Solution 8 - IphoneNarasimha NallamsettyView Answer on Stackoverflow
Solution 9 - IphoneNarasimha NallamsettyView Answer on Stackoverflow
Solution 10 - IphonebdvView Answer on Stackoverflow
Solution 11 - IphoneShashwatView Answer on Stackoverflow