Adding a target to a button programmatically throws an error “unrecognized selector sent to class”
问题 Not sure why I am getting an "Unrecognized selector sent to class" error when I try to use the button I've created in code. Here is my code: let sendButton: UIButton = { let button = UIButton(type: .system) button.setTitle("Send", for: .normal) button.setTitleColor(UIColor.white, for: .normal) button.backgroundColor = #colorLiteral(red: 0.5098039216, green: 0.5215686275, blue: 0.8392156863, alpha: 1) button.layer.cornerRadius = 5 button.isUserInteractionEnabled = true button.addTarget(self,