xcode 5中的instantiateViewControllerWithIdentifier [英] instantiateViewControllerWithIdentifier in xcode 5

查看:133
本文介绍了xcode 5中的instantiateViewControllerWithIdentifier的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用xcode 5中的故事板。我有一个导航控制器,我正在尝试建立故事板中其他场景的过渡。我首先尝试使用:

I'm working on a storyboard in xcode 5. I have a navigation controller, and am trying to establish the transitions to other scenes in my storyboard. I first tried using:

- (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上搜索我发现 2013年2月的这篇文章建议使用 instantiateViewControllerWithIdentifier

This would bring me to a black screen. Searching on stackoverflow I found this post from Feb 2013 which suggested using 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];
}

然而,这给了我一个错误

However, this gave me an error


Storyboard()不包含带有标识符'MPDetailPageViewController'的视图控制器

Storyboard () doesn't contain a view controller with identifier 'MPDetailPageViewController'

我试图弄清楚如何查找/设置标识符并看到引用 Storyboard ID 的帖子,但是当我在屏幕上看时我只看到恢复ID 我只能看到当我点击查看而不是 ViewController 本身。当我点击 ViewController 时,我看不到恢复ID ,也没有故事板ID

I tried figuring out how to find/ set the identifier and saw posts referencing Storyboard ID, but when I look on my screen I only see Restoration ID and I can only see that when I click on the View and not the ViewController itself. When I click on the ViewController, I don't see Restoration ID nor Storyboard ID

任何帮助都将不胜感激!

Any help would be greatly appreciated!

推荐答案

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

The Storyboard ID property can be found in the Identity Inspector of the View Controller:


  1. 打开你的故事板。

  2. 点击你视图下方的黑条用于显示您的详细信息。

  3. 确保右侧打开 Identity Inspector 。当您打开 Utilities 窗格时,它是顶部的第三个图标。

  4. 中的第二部分Identity Inspector 标记为Identity。列出的第一个属性是 Storyboard ID 。您可以将其值设置为MPDetailPageViewController。

  1. Open up your storyboard.
  2. Click on the black bar underneath the view you've designed to display your details.
  3. Make sure you have the Identity Inspector open on the right. It's the third icon at the top when you have the Utilities pane open.
  4. The second section in the Identity Inspector is labeled "Identity". The first property listed is Storyboard ID. You can set the value of it to "MPDetailPageViewController".

编辑:添加屏幕截图:

Added screen shot:

这篇关于xcode 5中的instantiateViewControllerWithIdentifier的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆