我想移到另一个视图控制器,但我不断收到错误消息:
无法将类型'App.ViewController'(0x106722db8)的值强制转换为'App.requirementVC'(0x106722d58)。
我已经检查了标识符ID和文件名,都很好。
这是我的代码
@IBAction func buttonOK(_ sender: Any) {
let button = (self.storyboard?.instantiateViewController(identifier: "RequirementsVC") as! requirementVC)
self.navigationController?.pushViewController(button, animated: true)
我是新手,所以我需要您的帮助。提前谢谢。
您可以执行以下操作...
@IBAction func buttonOK(_ sender: Any) {
let vc = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "RequirementsVC") as! requirementsVC
self.navigationController?.pushViewController(vc, animated: true)
}
这里Main
是情节提要的名称。