2014-01-21 41 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