Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

ios

I am having a problem with this. In my root view controller I am having a textfield & one button. I am giving a condition like if i entered 0 in textfield then only it should move to next view. upto here it is working correctly. But now here is problem. Here I am having one button & given navigation to third view controller for that button. here i am getting error as

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.'

image ref: http://img12.imageshack.us/img12/8533/myp5.png

and i am giving action for button in first view as below

- (IBAction)Submit:(id)sender {

if([tf.text isEqual:@"0"])
{

    UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main"   bundle:nil];

    SecondViewController *vc2 = [storyboard instantiateViewControllerWithIdentifier:@"SecondViewControllerID" ];

    [self presentViewController:vc2 animated:YES completion:NULL];

}  
}
like image 206
Boggarapu Avatar asked Oct 07 '13 11:10

Boggarapu


3 Answers

Go To:

Editor--> Embed In --> Navigation Controller, to add Navigation Controller to your initial view

like image 200
Mutawe Avatar answered Sep 28 '22 05:09

Mutawe


After looking at your screenshot, you either need to

  1. Push your SecondViewController onto the existing navigation controller's stack instead of presenting it modally OR
  2. You need to embed your SecondViewController in another navigation controller and then create and present that navigation controller modally from your SamplesViewController

Either way, SecondViewController needs to be embedded in a navigation controller before you can use Push Segues from it

like image 29
Jonathan Arbogast Avatar answered Sep 28 '22 06:09

Jonathan Arbogast


Either embed your view controller in a Navigation controller or if there is a Navigation controller in the story board mak it the initial view controller

like image 26
Muhammad Irfan Avatar answered Sep 28 '22 07:09

Muhammad Irfan