2014-01-21 56 views
1

我正在研究xcode 5中的一个故事板。我有一个导航控制器,并且正在尝试建立到故事板中其他场景的转换。我第一次尝试使用:instantiateViewControllerWithIdentifier in 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]; 
} 

这会把我带到黑屏。搜索在计算器我发现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]; 
} 

然而,这给了我一个错误

故事板()不包含标识符的视图控制器'MPDetailPageViewController'

我试图找出如何找到/设置识别呃看到帖子Storyboard ID,但是当我在屏幕上看时,我只看到Restoration ID,我只能看到当我点击View而不是ViewController本身。当我点击ViewController,我没有看到Restoration ID也没有Storyboard ID

任何帮助将不胜感激!

回答

17

Storyboard ID属性可以在视图控制器的Identity Inspector发现:

  1. 打开你的故事板。
  2. 点击黑条在您设计的视图下方显示您的详细信息。
  3. 确保您在右侧打开了Identity Inspector。当您打开Utilities窗格时,这是顶部的第三个图标。
  4. Identity Inspector中的第二部分标记为“标识”。列出的第一个房产是Storyboard ID。您可以将它的值设置为“MPDetailPageViewController”。

编辑:添加屏幕截图: enter image description here

+2

哦,这是令人尴尬的。我的“身份”部分只是最小化。必须点击它才能显示“Storyboard ID”和“Restoration ID”。谢谢你的帮助! – tombornal