Reputation: 3
I got first ViewController
with out navigation controller, I go from it to second ViewController
via
if (!self.mapViewController)
{
self.mapViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"MapViewController"];
}
[self presentViewController:self.mapViewController animated:YES completion:nil];
I send some data with prepareForSegue
to it, but I need that it also be with navigation controller.
I embed in a navigation controller in storyboard but my code still called second ViewController
with out navigation.
Upvotes: 0
Views: 44
Reputation: 620
I am not a professional with the way of the storyboard, however i believe that instead of presentViewController
you should be using the following function to present a storyboard VC based on segues.
[self performSegueWithIdentifier:@"SegueIdentifierHere" sender:nil];
Make sure that in your storyboard you have incorporated a UINavigationControllerVC as well.
Upvotes: 1
Reputation: 62676
Give an identifier to the navigation controller in storyboard. Instantiate and present that.
UINavigationController *navVC = [self.storyboard
instantiateViewControllerWithIdentifier:@"TheNavVCWhoseRootIsMyMapViewController"];
self.mapViewController = navVC.viewControllers[0]; // your map vc is at the root
[self presentViewController:navVC animated:YES completion:nil];
Upvotes: 0
Reputation: 2877
You are using presentViewController:animated:completion
which will indeed display a UIViewController
without the UINavigationController
the previous UIViewController
was embedded in.
Try using the following:
[self.navigationController pushViewController:self.mapViewController animated:YES]
Upvotes: 0