I am creating a subclass of a UIButton, the reason why I'm trying to intercept the touch is because I cant seem to find another way to receive 'press up' or 'press ended' events for the standard UIButton in tvOS. If I could find a way to do that then I wouldn't need to bother with the solution below.
pressesEnded(_ presses: Set<UIPress>, with event: UIPressesEvent?)
doesn't seem to be getting called every time I release the 'select' button on the Apple TV Remote.
pressesBegan(_ presses: Set<UIPress>, with event: UIPressesEvent?)
is being called every time without any issues. I've attached my code below. Any ideas what could be causing this issue?
class EVLPTZButton: UIButton
{
var command: PTZCommand!
var delegate: EVLPTZButtonCommandDelegate?
override func pressesBegan(_ presses: Set<UIPress>, with event: UIPressesEvent?)
{
super.pressesBegan(presses, with: event)
delegate?.ptzButton(pressesBeganFor: self, with: command)
}
override func pressesEnded(_ presses: Set<UIPress>, with event: UIPressesEvent?)
{
super.pressesEnded(presses, with: event)
delegate?.ptzButton(pressesEndedFor: self)
}
}