我不知道这是否有可能,但我使用xibs编写了一个项目,并希望通过模式切换到故事板项目。
我知道要换VC你做的事就像
NewViewController *NewVC = [[NewViewController alloc] init];
[self presentModalViewController:NewVC animated:YES];点击一个按钮,我就叫它“开关”
还有一个项目只使用故事板,我想用“开关”来称呼它。
我该怎么做呢?有可能这样做吗?
发布于 2014-01-28 17:37:02
是的是可能的。你可以这样做:
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"YourStoryboardName" bundle:nil];
MainMenuViewController *mainmenuvc = [storyboard instantiateViewControllerWithIdentifier:@"mainMenuViewController"];
[self.navigationController pushViewController:mainmenuvc animated:YES];编辑如果我理解您的评论,您需要更改根视图控制器。你可以这样做:
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"RVCStoryboard" bundle:nil];
MainMenuViewController *mainmenuvc = [storyboard instantiateViewControllerWithIdentifier:@"mainMenuViewController"];
[[UIApplication sharedApplication].delegate].window.rootViewController = mainmenuvc;请注意,要使其工作,在您的RVCStoryboard中,您必须选择要加载的视图控制器,并为其分配一个名称,以便instantiateViewControllerWithIdentifier:方法能够工作。检查附加的图像,字段"Storyboard ID":

https://stackoverflow.com/questions/21411079
复制相似问题