0

I have two UIViewController's that are StoryBoards. Let's say they are FirstVC and SecondVC. From FirstVC I want to present SecondVC with the following code.

UIViewController *secondVC;
secondVC = [self.storyboard instantiateViewControllerWithIdentifier:@"secondVC"];
[self.firstVC presentViewController: secondVC animated:YES completion:nil];

Now in StoryBoard I have embedded secondVC in a NavigationController, however, when presented, secondVC is missing the NavigationBar.

firstVC and secondVC are not connected via StoryBoard as I want to present them with code.

Am I missing something or have I done this the wrong way?

Stephen Fox
  • 14,190
  • 19
  • 48
  • 52
  • It looks like you're trying to do this: http://stackoverflow.com/questions/9674685/creating-a-segue-programmatically. – Larry Rubin Jun 09 '15 at 20:48
  • You need to assign an identifier to the UINavigationController scene and instantiate and present that scene. The storyboard process will automatically instantiate the embedded secondVC. You can also link the two scenes via a segue and still perform the segue through code using `performSegueWithIdentifier` – Paulw11 Jun 09 '15 at 20:56
  • You have to give the navigation controller in stroyboard a storyboard identifier and create and present that, not secondVC. – Rory McKinnel Jun 09 '15 at 20:59

0 Answers0