【发布时间】:2020-07-10 13:41:43
【问题描述】:
我不断收到错误:
无法将“我的项目在此处”(0x10f5e3f28) 类型的值转换为 'UINavigationController' (0x7fff897de6f0)。 (lldb)
单击与此代码关联的按钮时,我收到 SIGABRT 错误。
非常感谢任何想法。这是我的代码:
@IBAction func anonymousTapped(_ sender: UIButton) {
print("anonymous tapped")
let storyboard = UIStoryboard(name: "Main", bundle: nil)
let ChatVC = storyboard.instantiateViewController(withIdentifier: "ChatVC") as! UINavigationController
let appDelegate = UIApplication.shared.delegate as! AppDelegate
appDelegate.window?.rootViewController = ChatVC
}
【问题讨论】:
-
请edit您的问题显示代码。该错误表明您有一个自己的类的实例,而应为
UINavigationController。 -
这个简单的意思是故事板中标识符为“ChatVC”的控制器不是
UINavigationController- 请检查您的故事板和导航控制器的标识符