以编程方式调用情节提要场景(无需序列)? [英] Call storyboard scene programmatically (without needing segue)?
问题描述
我有一个模态情节提要板场景,我希望所有其他场景都可以访问该场景.从情节提要中的每个场景为其创建模态选择,将到处乱七八糟的字符串.有没有一种方法可以让我不再打扰,而是通过编程方式呼叫现场?
I have a modal storyboard scene that I want to be accessible to all my other scenes. Creating a modal segue to it from every scene on my storyboard creates a big mess of strings going everywhere. Is there a way that I leave off the segues and call the scene programmatically instead?
基本上我想做这样的事情:
Basically I want to do something like this:
MyNewViewController *myNewVC = [[MyNewViewController alloc] init];
[self presentModalViewController:myNewVC animated:YES];
除了要创建和推送视图控制器类之外,我想向隔离"(未与segue连接)故事板场景进行模式转换.
except instead of creating and pushing a view controller class, I want to do a modal transition to an "isolated" (not connected with a segue) storyboard scene.
推荐答案
可以.做这样的事情来访问VC,然后只需Modal Push即可:
Yes you can. Do something like this to get access to the VC, then just Modal Push it:
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard_iPhone" bundle:nil];
MyNewViewController *myVC = (MyNewViewController *)[storyboard instantiateViewControllerWithIdentifier:@"myViewCont"];
这篇关于以编程方式调用情节提要场景(无需序列)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!