I have created a button which I have assigned to my accessoryView. I get to see the created button, but when I press on it, nothing happens. Can anyone see what I'm doing wrong?
let accessoryButton = UIButton(type: .roundedRect)
accessoryButton.setTitle("message", for: .normal)
accessoryButton.sizeToFit()
accessoryButton.addTarget(self, action: #selector(goToMessaging(sender:)), for: UIControlEvents.touchUpInside)
cell.accessoryView = accessoryButton as UIView
@objc func goToMessaging(sender: UIButton){
print("message him")
}
Could it be because you are casting the button to a UIView?
You could try adding a tap gesture recognizer to the accessoryView if it has to be a UIView.