你能檢查你的vc
是不是零?
您有可選的storyboard
和強制as
,在推vc
之前,有幾件事可能會出錯。它可以是nil
,也可以不是GroupViewController
實例。
你可以通過嘗試這樣的東西開始:
if let vc = self.storyboard?.instantiateViewController(withIdentifier: "group") as? GroupViewController {
self.navigationController?.pushViewController(vc, animated: true)
}
,看你是否真正得到非空vc
。
編輯:根據你的評論 - 看起來你確實得到nil
在某些時候。然後你需要檢查確切的地方。你的self.storyboard
是不是零?
你可以實例化你的視圖控制器嗎? method docs
If the specified identifier does not exist (or is nil) in the storyboard file, this method raises an exception.
我建議打破你實例爲單獨的步驟,並檢查他們每個人這樣的調試:在控制檯
if let storyboard = self.storyboard {
let vc = storyboard.instantiateViewController(withIdentifier: "group")
if let groupVC = vc as? GroupViewController {
self.navigationController?.pushViewController(groupVC, animated: true)
}
}
來源
2017-06-20 08:52:42
iur
任何消息? – Larme
@Larme在控制檯沒有消息。您的故事板中的 – joethemow
Groupviewcontroller是否按組識別? –