你能检查你的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是否按组识别? –