我正在尝试切换到另一个视图控制器,它在模拟器中工作得很好。但是当在设备上这样做时,它只是崩溃和回调:
致命错误:在展开可选值时意外找到零
我得到的同样的回调是,我试着在故事板上翻阅,如下所示:
func letsGoPressed(sender: UIButton!) {
performSegueWithIdentifier("goToQuestions", sender: self)
}或者如果我试着像这样instantiateViewControllerWithIdentifier:
func letsGoPressed(sender: UIButton!) {
let questionsGameVC: QuestionsGame = self.storyboard?.instantiateViewControllerWithIdentifier("Questions") as! QuestionsGame
var modalStyle: UIModalTransitionStyle = UIModalTransitionStyle.CoverVertical
questionsGameVC.modalTransitionStyle = modalStyle
self.presentViewController(questionsGameVC, animated: true, completion: nil)
}它们都在模拟器上工作,而不是在设备上!??!
发布于 2015-07-18 12:24:11
听起来,故事板的缓存版本没有带有goToQuestions标识符的Questions segue或视图控制器。
您还可以在这里删除: QuestionsGame:
let questionsGameVC: QuestionsGame = self.storyboard?.instantiateViewControllerWithIdentifier("Questions") as! QuestionsGame由于您正在使用as!显式地转换类型,所以不需要也声明该类型。
https://stackoverflow.com/questions/31490512
复制相似问题