按下uibutton会导致(lldb)EXC_BAD_INSTRUCTION错误

时间:2018-10-08 23:13:06

标签: ios uibutton swift4 presentviewcontroller

因此,当我触摸该按钮时,我的视图控制器未显示其他视图控制器。而是在代码的最后一行收到错误:

线程1:EXC_BAD_INSTRUCTION(代码= EXC_I386_INVOP,子代码= 0x0)。

调试控制台还显示以下消息: (lldb)

我正在尝试从getStarted页面导航到我的signUp页面。

感谢您的帮助。

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)
}

2 个答案:

答案 0 :(得分:0)

请检查是否已分配自定义类(SignUpViewController)以在情节提要中查看控制器,还请检查是否已正确分配标识情节提要ID'SignUpViewController'(区分大小写)。如下所示:Show how to assign custom class & identifier

答案 1 :(得分:0)

请提供情节提要名称和情节提要ID,以便您可以轻松导航

$image_count: 5;
$image_url: 'url(star.svg)';
$image_position: '0';

@for $i from 1 through ($image_count - 1) {
    $image_url: #{ $image_url+', '+$image_url };
    $image_position: #{ $image_position+', '+($i * (100% / $image_count)) };
}

.star-rating {
    background-image: $image_url;
    background-position: $image_position;
    background-size: 20px;
    background-repeat: no-repeat;
}