Calling storyboard from UIViewcontroller

ios, modal-dialog, storyboard, uiviewcontroller

Solution

Yes it is possible. You can do something like this:

UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"YourStoryboardName" bundle:nil];
MainMenuViewController *mainmenuvc = [storyboard instantiateViewControllerWithIdentifier:@"mainMenuViewController"];
[self.navigationController pushViewController:mainmenuvc animated:YES];

EDIT If I understand your comment, you want to change the root view controller. You can do so by:

UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"RVCStoryboard" bundle:nil];
MainMenuViewController *mainmenuvc = [storyboard instantiateViewControllerWithIdentifier:@"mainMenuViewController"];
[[UIApplication sharedApplication].delegate].window.rootViewController = mainmenuvc;

Please note that for this to work, in your RVCStoryboard you have to select the viewcontroller you are trying to load, and assign a name to it so that the `instantiateViewControllerWithIdentifier:` method will work. Check the attached image, the field "Storyboard ID":

Problem

I don't know if this is possible or not but I wrote a project using xibs and want to modally switch to a storyboard project. I know that to switch VC's you do something like ``` NewViewController *NewVC = [[NewViewController alloc] init]; [self presentModalViewController:NewVC animated:YES]; ``` upon clicking a button, that I'll call "switch" There is another project using solely storyboards that I want to call using "switch" How do I go about doing this? Is it possible to do this?

Original source