I have a subclass of a UIButton:
import UIKit
class CustomButton: UIButton {
required init?(coder decoder: NSCoder) {
super.init(coder: decoder)
//Customize Button Appearence Here..
}
}In interface builder, in storyboards, under my main view controller, I dragged and dropped a stock button, and changed it's 'Custom Class' to CustomButton from the drop down menu.
Wired it's 'Touch Up Inside' event to an IBAction.
Custom code for appearance shows up, but the button is not firing the 'Touch Up Inside'.
When I checked for touch events (touch began, ended, eat) within the subclass, the button seems to be receiving touch.
I copied your code and put a CustomButton on the storyboard, and connected its Touch Up Inside event to the ViewController's customButtonPressed(_:) method, I'm sure the action method was called.
One possibility is that you have mis-connected the 'Touch Up Inside' event. Try re-connecting it or call addTarget(_:action:forControlEvents:) manually.
Other possibilities ..., cannot guess without more info.