xcode 5中的instantiateViewControllerWithIdentifier

tom*_*nal 1 iphone xcode objective-c ios xcode5

我正在使用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];
}
Run Code Online (Sandbox Code Playgroud)

这会让我陷入黑屏.在stackoverflow上搜索我发现2013年2月的这篇帖子建议使用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];
}
Run Code Online (Sandbox Code Playgroud)

但是,这给了我一个错误

Storyboard()不包含标识符为"MPDetailPageViewController"的视图控制器

我试图弄清楚如何查找/设置标识符并看到帖子引用Storyboard ID,但当我在屏幕上看时我只看到Restoration ID,我只能看到当我点击View而不是它ViewController自己.当我点击它时ViewController,我看不到Restoration ID也没有Storyboard ID

任何帮助将不胜感激!

and*_*oft 17

Storyboard ID属性可以Identity Inspector在View Controller中找到:

  1. 打开你的故事板.
  2. 单击您设计的视图下方的黑条以显示您的详细信息.
  3. 确保你Identity Inspector在右边打开.当Utilities窗格打开时,它是顶部的第三个图标.
  4. 第二部分Identity Inspector标有"身份".列出的第一个属性是Storyboard ID.您可以将其值设置为"MPDetailPageViewController".

编辑:添加屏幕截图: 在此输入图像描述

  • 哦,这很尴尬.我的"身份"部分最小化了.必须点击它才能显示"故事板ID"和"恢复ID".谢谢你的帮助! (2认同)