2015-10-14 122 views
0

enter image description here移動到下一個視圖控制器,我用故事板

這裏是我的代碼

RadarViewController *wc = [[RadarViewController alloc] 
           initWithNibName:@"RadarViewController" 
           bundle:nil]; 

[self.navigationController pushViewController:wc animated:YES]; 

這裏是錯誤出現崩潰的應用程序後。

The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKit/UIView.h> may also be helpful. 
2015-10-14 12:25:02.596 Quick man help[890:60170] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Could not load NIB in bundle: 'NSBundle </Users/brainpulse/Library/Developer/CoreSimulator/Devices/0FD1A490-11AF-468D-96D3-71F37DDD8552/data/Containers/Bundle/Application/35FDBB50-E294-458B-B367-A57E3FC0B594/Quick man help.app> (loaded)' with name 'RadarViewController'' 
+0

你的雷達觀察控制器在故事板? – NiravPatel

+0

是的,它在我的故事板中。 –

回答

2

您的Xcode不能找到名爲「RadarViewController」因爲你使用一個故事板廈門國際銀行....

你需要從故事板創建RadarViewController的實例像

UIStoryboard *mystoryboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil]; 
radarVC = [mystoryboard instantiateViewControllerWithIdentifier:@"radarVCID"]; 

你需要將雷達VCID設置爲故事板中的RadarViewController的storyboardID

+0

我已經做到了,請找到我的radarviewcontroller的屏幕快照。 –

+0

RadarViewController * wc = [[RadarViewController alloc] initWithNibName:@「RadarViewController」 bundle:nil];您還需要更改此代碼 –

0

做下面的事情。

1)選擇在故事板

2)在身份檢查RadarViewController,給RadarViewController標識符Storyboard ID。例如,「捕捉」,你可以在截圖中看到

enter image description here

現在喜歡寫東西的下面。

RadarViewController *obj = [self.storyboard instantiateViewControllerWithIdentifier:@"youridentifier"];//youridentifier =capture as per screenshot. You can give whatever identifier to `RadarViewController` 

[self.navigationController pushViewController:obj animated:YES]; 

讓我知道它工作與否。

快樂編碼!

+0

感謝您的回覆,但我已經完成了與捕獲圖像相同的操作,同樣是應用程序崩潰,並提供了我提到的錯誤。 –

+0

RadarViewController在您的項目中是否有任何XIB?因爲你的錯誤是說「無法在包中加載NIB」 – NiravPatel

+0

你使用過NavigationController嗎? – NiravPatel

0

似乎並不是所有連接都作爲檔案的一部分已經從故事板中加載,此刻您撥打initWithNibNameinstantiateViewControllerWithIdentifier一樣。 我建議你在viewDidLoad上安裝你的視圖控制器。 如果它不起作用,請嘗試查看您的故事板是否正確。要做到這一點打開它的源代碼,並期待在打開/關閉標籤 enter image description here

了這一切後,刪除你瀏覽器並重新add.Don't忘記執行所有之前創建的故事板的副本這個的。

相關問題