识别 UIStoryboard [英] Identifying a UIStoryboard

查看:24
本文介绍了识别 UIStoryboard的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何识别 UIStoryboard?

How do you identify a UIStoryboard?

该类具有创建和实例化的方法,但我没有看到类似 name 的 @property.例如

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

获取故事板对象

+ storyboardWithName:bundle:

实例化 Storyboard 视图控制器

Instantiating Storyboard View Controllers

– instantiateInitialViewController
– instantiateViewControllerWithIdentifier:

有什么建议吗?

====更新

我希望像 self.storyboard.name[self.storyboard description] 之类的东西,例如:

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

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

也许不是这样.

推荐答案

您可以在项目导航器中通过名称识别故事板:

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

您可以通过在界面构建器的身份检查器中设置故事板 ID 来从故事板中识别视图控制器:

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

这篇关于识别 UIStoryboard的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆