Swift 线程1:使用UIButton执行错误指令

Swift 线程1:使用UIButton执行错误指令,swift,button,Swift,Button,在我的应用程序中,我同时使用故事板和直接编程。 在一个视图上,我想使用编程按钮转到另一个视图 这是密码 func QuitView(sender:UIButton){ self.presentViewController(FirstViewController(), animated: true, completion: nil) } 错误是: 线程1 exc_bad_指令(代码=exc_i386_invop子代码=0x0)错误 在黑暗中疯狂拍摄,但看起来您正试图返回第一个视图控制

在我的应用程序中,我同时使用故事板和直接编程。 在一个视图上,我想使用编程按钮转到另一个视图 这是密码

  func QuitView(sender:UIButton){
    self.presentViewController(FirstViewController(), animated: true, completion: nil)
}
错误是:

线程1 exc_bad_指令(代码=exc_i386_invop子代码=0x0)错误


在黑暗中疯狂拍摄,但看起来您正试图返回第一个视图控制器,因此请执行
self。dismissViewController(动画:true)

An将有助于识别问题