我想对多个场景使用相同的 ViewController。现在我想根据使用的场景实现稍微不同的行为。我想这可以使用标识符来实现。就像(伪代码)
if (self.identifier == scene1)
{
// do this
}
else if (self.identifier == scene2)
{
// do that
}
如何从 ViewController 调用标识符?
编辑:
我的意思是来自检查器的这个标识符 - 我如何在代码中调用它?
提前致谢。
最佳答案
我修好了。一种可能的方法是命名 Segway 标识符,然后在prepareForSegue 方法中检查相等的字符串。
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
if ([segue.identifier isEqualToString:@"HelpSegue"])
{
// do this
}
else
{
// do that
}
}
关于iphone - 使用一个 ViewController 处理多个场景,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11280863/