按 uibutton 会导致 (lldb) 错误 EXC_BAD_INSTRUCTION
Pressing uibutton causes (lldb) error with EXC_BAD_INSTRUCTION
所以当触摸按钮时,我的视图控制器没有显示另一个视图控制器。相反,在代码的最后一行我收到错误:
线程 1:EXC_BAD_INSTRUCTION(代码=EXC_I386_INVOP,子代码=0x0)。
调试控制台还显示消息:
(lldb)
我正在尝试从我的 getStarted 页面导航到我的注册页面。
感谢您的帮助。
let getStartedButton: UIButton = {
let getStartedButton = UIButton()
getStartedButton.backgroundColor = UIColor(red:0.24, green:0.51, blue:0.59, alpha:1.0)
getStartedButton.setTitle("Get Started", for: .normal)
getStartedButton.titleLabel?.font = UIFont(name: "Helvetica Bold", size: 18)
getStartedButton.translatesAutoresizingMaskIntoConstraints = false
getStartedButton.addTarget(self, action: #selector(buttonAction), for: .touchUpInside)
return getStartedButton
}()
@objc func buttonAction(sender: UIButton!) {
let destinationVC = self.storyboard?.instantiateViewController(withIdentifier: "SignUpViewController") as! SignUpViewController
self.present(destinationVC, animated: true, completion: nil)
}
请检查您是否将自定义 class (SignUpViewController) 分配给故事板中的视图控制器,同时检查您是否正确分配了身份故事板 ID 'SignUpViewController'(区分大小写)。如下所示:
请提供情节提要名称和情节提要 ID,以便您轻松导航
let storyboard = UIStoryboard(name: "MyStoryboardName", bundle: nil)
let destinationVC : SignUpViewController = storyboard.instantiateViewController(withIdentifier: "SignUpViewController")
self.present(destinationVC, animated: true, completion: nil)
所以当触摸按钮时,我的视图控制器没有显示另一个视图控制器。相反,在代码的最后一行我收到错误:
线程 1:EXC_BAD_INSTRUCTION(代码=EXC_I386_INVOP,子代码=0x0)。
调试控制台还显示消息: (lldb)
我正在尝试从我的 getStarted 页面导航到我的注册页面。
感谢您的帮助。
let getStartedButton: UIButton = {
let getStartedButton = UIButton()
getStartedButton.backgroundColor = UIColor(red:0.24, green:0.51, blue:0.59, alpha:1.0)
getStartedButton.setTitle("Get Started", for: .normal)
getStartedButton.titleLabel?.font = UIFont(name: "Helvetica Bold", size: 18)
getStartedButton.translatesAutoresizingMaskIntoConstraints = false
getStartedButton.addTarget(self, action: #selector(buttonAction), for: .touchUpInside)
return getStartedButton
}()
@objc func buttonAction(sender: UIButton!) {
let destinationVC = self.storyboard?.instantiateViewController(withIdentifier: "SignUpViewController") as! SignUpViewController
self.present(destinationVC, animated: true, completion: nil)
}
请检查您是否将自定义 class (SignUpViewController) 分配给故事板中的视图控制器,同时检查您是否正确分配了身份故事板 ID 'SignUpViewController'(区分大小写)。如下所示:
请提供情节提要名称和情节提要 ID,以便您轻松导航
let storyboard = UIStoryboard(name: "MyStoryboardName", bundle: nil)
let destinationVC : SignUpViewController = storyboard.instantiateViewController(withIdentifier: "SignUpViewController")
self.present(destinationVC, animated: true, completion: nil)