2015-05-13 78 views
0

切換視圖控制器我試着在一個項目中,我正在與雨燕切換視圖控制器。我希望它在ViewController - > SecondViewController之間切換。所以我把這段代碼放到ViewController.Swift中,而不是放到SecondViewController中。在斯威夫特代碼

let homeViewController = self.storyboard?.instantiateViewControllerWithIdentifier("SecondController") as! SecondViewController 
      self.navigationController?.pushViewController(SecondViewController(), animated: true) 

我得到一個線程1:signal SIGABRT。

如果我必須把我的代碼放到SecondViewController,哪裏會我把它?

+0

你從哪裏得到'信號SIGABRT'?你會得到什麼例外? –

回答

0

做這樣的。

let homeViewController = self.storyboard?.instantiateViewControllerWithIdentifier("SecondController") as! SecondViewController 
      self.navigationController?.pushViewController(homeViewController, animated: true) 

您的所有視圖控制器都在導航控制器容器中嗎?

+0

線程1:信號SIGABRT –

+0

你有沒有把視圖控制器中的UINavigationController。如果你已經放入導航控制器,那麼崩潰是在別的地方。 – Amit89