在xcode 5中实例化ViewControllerWithIdentifier

我正在Xcode 5的故事板上工作。我有一个导航控制器,并试图build立到故事板中其他场景的转换。 我第一次尝试使用:

- (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上search我发现这个post从2013年2月build议使用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”的视图控制器

我试图找出如何find/设置标识符,并看到post引用Storyboard ID ,但是当我看我的屏幕上,我只看到Restoration ID ,我只能看到,当我点击View而不是ViewController本身。 当我点击ViewController ,我看不到Restoration IDStoryboard ID

任何帮助将不胜感激!

Storyboard ID属性可以在View Controller的Identity Inspector中find:

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

编辑:添加屏幕截图: 在这里输入图像说明