【发布时间】:2012-10-22 18:48:45
【问题描述】:
我可以将视图的名称作为 switch 语句的参数吗?如果是这样,我将在 switch 中使用什么?
[self addChildViewController:[self.storyboard instantiateViewControllerWithIdentifier:@"View1"]];
[self addChildViewController:[self.storyboard instantiateViewControllerWithIdentifier:@"View2"]];
[self addChildViewController:[self.storyboard instantiateViewControllerWithIdentifier:@"View3"]];
[self addChildViewController:[self.storyboard instantiateViewControllerWithIdentifier:@"View4"]];
[self addChildViewController:[self.storyboard instantiateViewControllerWithIdentifier:@"View5"]];
[self addChildViewController:[self.storyboard instantiateViewControllerWithIdentifier:@"View6"]];
[self addChildViewController:[self.storyboard instantiateViewControllerWithIdentifier:@"View7"]];
[self addChildViewController:[self.storyboard instantiateViewControllerWithIdentifier:@"View8"]];
[self addChildViewController:[self.storyboard instantiateViewControllerWithIdentifier:@"View9"]];
[self addChildViewController:[self.storyboard instantiateViewControllerWithIdentifier:@"View10"]];
根据视图名称,我想在标签中显示不同的文本。所以我想要一个开关,其中案例是视图的名称,我只是不知道如何返回视图的名称,以便我可以检查它们。
谢谢。
【问题讨论】:
-
如果你的名字在一个字符串中,你就不需要开关了。如果您试图在运行时获取 变量 的标签,那么您可以为 ivars 执行此操作,但几乎可以肯定这是错误的方法。请详细说明您要完成的工作。
标签: objective-c uiviewcontroller storyboard switch-statement