UIStoryboard:获取活动故事板的正确方法是什么? [英] UIStoryboard: What's the Correct Way to Get the Active Storyboard?
问题描述
我目前正在疯狂地挖掘所有文档,并且还没有找到我正在寻找的东西。我怀疑这是真正的哦!回答。
I am currently furiously digging through all the docs, and haven't quite found what I'm looking for. I suspect it is a real d'oh! answer.
我只需要在主要包中找到活动的故事板,并想知道最好的方法。
I simply need to find the active storyboard in the main bundle, and want to know the best way to do this.
这样我就可以使用 [UIStoryboard storyboardWithName:@XXXbundle:mainBundle]
来提取正在运行的故事板。
This is so that I can use the [UIStoryboard storyboardWithName:@"XXX" bundle:mainBundle]
to extract the running storyboard.
我知道如何通过打开成语来克服它,但我觉得这是一个... kludge。
I know how to kludge it by switching on the idiom, but I feel that this is a...kludge.
什么是这样做的正确方法是什么?
What's a correct way of doing this?
更新:
好的。我找到了。
像往常一样, on Stack Overflow (官方Apple文档站点;)。
As usual, on Stack Overflow (the official Apple Documentation Site ;).
以下是我确定的代码:
UIStoryboard *st = [UIStoryboard storyboardWithName:[[NSBundle mainBundle].infoDictionary objectForKey:@"UIMainStoryboardFile"] bundle:[NSBundle mainBundle]];
推荐答案
好的。正如我上面的评论所表明的那样,我找到了(错误措辞问题)的答案:
OK. As my comment above indicates, I found the answer to the (badly phrased question):
我希望能够获得 main (不是活动)故事板,因为我没有使用每个化身的多个故事板。我使用的是iPhone的1个故事板的标准型号,iPad的1个标准型号。我只想要最简洁的方法来获取故事板,以便我可以使用它来生成视图控制器。
I wanted to be able to get the main (not active) storyboard, as I'm not using multiple storyboards per incarnation. I'm using the standard model of 1 storyboard for iPhone, and 1 for iPad. I just wanted the cleanest way to get the storyboard, so that I could use it to generate a view controller.
我在关于Stack Overflow的这篇文章,并使用以下代码实现它:
I found the answer in this post on Stack Overflow, and implemented it with the following code:
UIStoryboard *st = [UIStoryboard storyboardWithName:[[NSBundle mainBundle].infoDictionary objectForKey:@"UIMainStoryboardFile"] bundle:[NSBundle mainBundle]];
这篇关于UIStoryboard:获取活动故事板的正确方法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!