我正在使用xcode 5中的故事板。我有一个导航控制器,我正在尝试建立故事板中其他场景的过渡。我第一次尝试使用:
- (IBAction)handleTap:(UITapGestureRecognizer *)sender {
NSLog(@"Image clicked");
_detailPage = [[MPDetailPageViewController alloc] initWithNibName:@"MPDetailPageViewController" bundle:nil];
_detailPage.product = _curProduct;
//Bring to detail page
[self.navigationController pushViewController:self.detailPage animated:YES];
}
这会让我陷入黑屏。在stackoverflow上搜索,我发现this post from Feb 2013建议使用instantiateViewControllerWithIdentifier
所以我试过了:
- (IBAction)handleTap:(UITapGestureRecognizer *)sender {
NSLog(@"Image clicked");
_detailPage = [self.storyboard instantiateViewControllerWithIdentifier:@"MPDetailPageViewController"];
_detailPage.product = _curProduct;
//Bring to detail page
[self.navigationController pushViewController:self.detailPage animated:YES];
}
然而,这给了我一个错误
Storyboard()不包含标识符为“MPDetailPageViewController”的视图控制器
我尝试了解如何查找/设置标识符并看到引用Storyboard ID
的帖子,但当我在屏幕上看时,我只看到Restoration ID
,我只能看到当我点击View
而不是ViewController
本身。当我点击ViewController
时,我看不到Restoration ID
或Storyboard ID
非常感谢任何帮助!
答案 0 :(得分:17)
Storyboard ID
属性可以在View Controller的Identity Inspector
中找到:
Identity Inspector
。当您打开Utilities
窗格时,它是顶部的第三个图标。Identity Inspector
中的第二部分标有" Identity"。列出的第一个属性是Storyboard ID
。您可以将其值设置为" MPDetailPageViewController"。编辑:添加了屏幕截图: