我可以将视图的名称作为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"]];
根据视图名称,我想在标签中显示不同的文本位。所以我想要一个开关,其中的情况是视图的名称我只是不知道如何返回视图的名称,所以我可以检查它们。
谢谢。
如果你有名字_in一个string_已经,你并不需要一个开关。如果你想在运行时获得_variable_的标签,那么你可以为ivars做到这一点,但它几乎肯定是错误的方式。请详细说明你想要完成什么。 –
编辑我的问题 – Lewis