加载视图表单没有Segue的StoryBoard [英] load view form StoryBoard that does not have a Segue
问题描述
我真的很喜欢将我的所有视图都放在故事板中,但有时我会根据代码生成的按钮显示一个视图,这样就没有Segue引用 - 它将是在故事板中完全断开连接。我仍然想在故事板中设计它,所以我可以对我的所有屏幕都有一个很好的概述。
I am really liking having all of my view's laid out in the Storyboard but there are times when I will have a view that is shown based on a button that is generated by code so there will be no Segue reference - it will be totally disconnected in the Storyboard. I would still like to design it in the storyboard though so I can have a nice overview of all my screens.
我是否有可能加载XIB(或其他任何东西)加载UIViewControler时在故事板中设计的故事板?
Is it possible for me to load the XIB (or whatever it is in a storyboard) designed in the storyboard when a UIViewControler is loaded?
推荐答案
我在我的项目中这样做:
I do this in my projects:
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
UIViewController *myController = [storyboard instantiateViewControllerWithIdentifier:@"MyViewController"];
[self.navigationController pushViewController: myController animated:YES];
请确保您已正确设置控制器的标识符。您可以通过以下方式执行此操作:
Just make sure you have set your controller's identifier correctly. You can do this by:
- 在工具面板中选择故事板中的控制器
- ,单击属性检查器。无论你决定放入Identifier字段,都会在'instantiateViewControllerWithIdentifier'语句中找到。
我希望这会有所帮助。
这篇关于加载视图表单没有Segue的StoryBoard的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!