title: Embed a UIViewController in a NavigationController using segues
body: <p>I have a viewController that is <em>usually</em> (most often) accessed by using a push segue. This viewController needs to be embedded in a UINavigationController. So typically, this is no problem. The push segue manages pushing the viewController, and therefore the viewController has it's UINavigationController.</p>
  <p>My issue is that in a few cases, I'd like to present this same exact viewController using a modal segue. When I do this, the viewController is not embedded in a navigationController. Is there a way to do this using segues?</p>
  <p>I know this can be done purely in code without segues by creating a UINavigationController, setting the rootView as the viewController and then presenting that modally. That can be done using code like this :</p>
  <pre><code>MyViewController *viewController = [[MyViewController alloc] init];
  UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:viewController];
  [self presentModalViewController:navController animated:YES];
  </code></pre>
  <p>But how do I do this same thing but using Segues?</p>
  <h2>Update</h2>
  <hr />
  <p>For further clarity, here is some code to supplement how I used the accepted answer in the prepareForSegue method.</p>
  <p><strong>When Using Modal Segue</strong></p>
  <pre><code>- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
  {
      if ([[segue destinationViewController] isEqualToString:@&quot;Modal to MyVC&quot;])
      {
          UINavigationController *nav = [segue destinationViewController];
          MyViewController *vc = [nav topViewController];
          //setup vc
      }
  }
  </code></pre>
  <p><strong>When Using Push Segue</strong></p>
  <pre><code>- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
  {
      if ([[segue destinationViewController] isEqualToString:@&quot;Push to MyVC&quot;])
      {
          MyViewController *vc = [segue destinationViewController];
          //setup vc
      }
  }
  </code></pre>