【发布时间】:2016-05-15 22:54:56
【问题描述】:
我尝试了几种不同的答案,但尚未找到有效的答案。
我不断得到
fatal error: unexpectedly found nil while unwrapping an Optional value
我的 GameViewController 中有一个名为 selectUpgrade 的 SKScene,我正在尝试转到一个名为 MissileUpgrade 的 UIViewController。
var vc2 = MissileUpgrade() //trying to get to this UIViewController
var gameVC = GameViewController() // currently in a scene in this UIViewController
我在我的场景中调用它来继续
func goToMissileUpgrade() {
gameVC.presentViewController(vc2, animated: true, completion: nil)
}
这些在同一个故事板中。如果我将 MissileUpgrade 设置为初始 VC,它将正常加载,所以我知道它与此无关。我不知道为什么这不起作用。感谢您的帮助!
【问题讨论】:
-
如果你目前在
GameViewController,你的代码不应该是self. presentViewController而不是gameVC.presentViewController吗? -
我在一个名为 selectUpgrade 的 SKScene 中,所以当我这样做时,我收到错误“selectUpgrade”有所以成员“presentViewController”
-
好的,它在哪一行崩溃?
gameVC或vc2是零吗? -
gameVC.presentViewController(vc2, 动画: true, 完成: nil)
标签: ios swift uiviewcontroller segue presentviewcontroller