UIStoryboard: What's the Correct Way to Get the Active Storyboard?

后端 未结 4 2027
无人及你
无人及你 2020-12-13 03:56

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 th

4条回答
  •  北荒
    北荒 (楼主)
    2020-12-13 04:27

    OK. As my comment above indicates, I found the answer to the (badly phrased question):

    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.

    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]];
    

提交回复
热议问题