2015-06-20 41 views
0

如何以編程方式推送導航控制器上的下一個視圖控制器(不需要按鈕)?如何以編程方式推動導航控制器上的下一個視圖控制器?

我知道如何實例並提出了新的控制器是低於

var next = self.storyboard?.instantiateViewControllerWithIdentifier("PlaceInfo") as! PlaceInfoController   
self.presentViewController(next, animated: false, completion: nil) 

但我想推到導航控制器上的下一個視圖控制器。 我試過下面self.navigationController?.pushViewController(),但沒有成功

var next = self.storyboard?.instantiateViewControllerWithIdentifier("PlaceInfo") as! PlaceInfoController 
self.navigationController?.pushViewController(next, animated: true) 
+0

有你,如果檢查'self.navigationController'是'nil'與否? – Leo

+0

它是零。任何想法爲什麼?預先感謝你@Leo – LuAndre

+0

這意味着這個viewController不在導航堆棧中,首先你必須把它放到一個導航堆棧中,然後你可以推另一個 – Leo

回答

0
+0

是的,應用程序崩潰。錯誤:由於未捕獲異常'NSGenericException'而終止應用程序,原因:'無法找到用於segue'PushPlaceView'的導航控制器。只有當源控制器由UINavigationController的實例管理時,才能使用推塞網。 @rodrigochousal – LuAndre

+0

由於@Leo說,應用程序崩潰,視圖控制器需要在導航堆棧中工作。 – rodrigochousal

相關問題