I have a UIStoryboard
that consists of 4 to 5 ViewControllers
. These ViewControllers
are connected with each other through push segue. This story board is not embedded inside NavigationController
.
Now i have to use this UIStoryboard
on two different scenario in my application.
This
UIStoryboard
is pushed inside aViewController
which is already inside aNavigationController
so i can simply do like this.UIStoryboard *myStoryboard = [UIStoryboard storyboardWithName:@"myStoryboard" bundle:nil]; UIViewController *vc = (UIViewController *)[myStoryboard instantiateInitialViewController]; [self.navigationController pushViewController:vc animated:YES];
This works perfectly fine as we are pushing the UIStoryboard
inside a NavigationController
so for further navigation UIStoryboard's
ViewControllers
can use the NavigationController
in which the story board is pushed.
The second scenario is that is have to modally present this
UIStoryBoard
from a viewController which i can do like.UIStoryboard *myStoryBoard = [UIStoryboard storyboardWithName:@"myStoryBoard" bundle:nil]; UIViewController *vc = [myStoryBoard instantiateInitialViewController];
[self presentViewController:vc animated:YES completion:^{
}];
It is presented successfully but now as the UIStoryboard
is not in any NavigationController
when i do a push Seque from first ViewController
to second ViewController
inside the UIStoryboard
it crashes (which it should) saying
Could not find a navigation controller for segue. Push segues can only be used when the source controller is managed by an instance of UINavigationController.'
Can some body tell how i can solve this problem or how i can programmatically embed or remove the UIStoryboard
inside the NavigationController