Identifying a UIStoryboard

岁酱吖の 提交于 2019-12-10 13:59:51

问题


How do you identify a UIStoryboard?

The class has methods which create and instantiate but I don't see an @property with something like name. E.g.

Getting a Storyboard Object

+ storyboardWithName:bundle:

Instantiating Storyboard View Controllers

– instantiateInitialViewController
– instantiateViewControllerWithIdentifier:

Any suggestions?

==== UPDATE

I was hoping for something like self.storyboard.name or [self.storyboard description], e.g.:

NSLog(@"This Storyboard is: %@", self.storyboard.name);

Perhaps it's not meant to be.


回答1:


You can identify a storyboard by its name in the project navigator:

You can identify a view controller from a storyboard by setting its Storyboard ID in the identity inspector in interface builder:

Once you have these, then you can access them through your code:

UIStoryboard *iPhoneStoryboard = [UIStoryboard storyboardWithName:@"MainStoryboard_iPhone" bundle:nil];
ViewController *firstViewController = [iPhoneStoryboard instantiateViewControllerWithIdentifier:@"FirstViewController"];


来源:https://stackoverflow.com/questions/16061624/identifying-a-uistoryboard

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!