2017-04-23 50 views
-1

我花了6個小時來解決問題,但它仍然是這樣....我想推我的LoginController到MainViewController,然後,編譯器彈出這個紅點,它說參議會傳遞給那個不需要任何爭論。我希望每個人都可以幫我一個法弗~~~~ enter image description here如何解決導航控制器的代碼

+1

請不要張貼代碼截圖,將確切的錯誤消息和代碼發佈爲可進行搜索和粘貼的文本。 – luk2302

+1

從錯誤消息中可以清楚看到。你所調用的函數「instantiateInitialViewController」沒有輸入參數。看看文檔。 – Fogmeister

+0

對不起luk2303,我不知道你在說什麼...因爲我發佈的截圖涉及到消息錯誤。 –

回答

2

嘗試使用實例查看控制器:

let mainViewController = self.storyboard?.instantiateViewController(withIdentifier: "MainViewController") as? MainViewController 

而且我認爲它能夠更好地使用,如果讓的情況下調用失敗

if let mainViewController = self.storyboard?.instantiateViewController(withIdentifier: "MainViewController") as? DetailViewController { 
} 
+0

謝謝,兄弟。你幫了我很多。其實,我還有一個問題....我用不同的故事板設置了不同的文件。當我在代碼上面輸入時,控制檯說故事板找不到MainViewController。你能教我爲什麼?thx ^^ –

+1

它更好地創建一個新的問題,如果我不能解決它的兄弟,等待這個不解決? – shearos

+0

無論如何,我認爲這可能是因爲故事板只有在Main.storyboard中創建MainViewController並且標識符爲「MainViewController」時才起作用。 如果您創建MainViewController.swift編程,試試這個: 讓MVC = MainViewController() self.navigationController pushViewController(MVC,動畫:真)? – shearos