That cannot work, unfortunately.
I tested for the event rawValue, to no avail, even after changing event type in the @objC:
@objc func handleButtonEvent(_ sender: UIButton, forEvent event: UIControl.Event) {
touchDown 1
touchDownRepeat 2
touchDragInside 4
touchDragOutside 8
touchDragEnter 16
touchDragExit 32
TouchUpInside 64
touchUpOutside 128
TouchCancel 256
PrimaryActionTriggered 8192
As explained here: https://stackoverflow.com/questions/31122418/in-swift-how-do-you-detect-which-uicontrolevents-triggered-the-action
Curiously, none of the action selector parameters provide any way to learn which control event triggered the current action selector call! Thus, for example, to distinguish a Touch Up Inside control event from a Touch Up Outside control event, their corresponding target–action pairs must specify two different action handlers; if you dispatch them to the same action handler, that handler cannot discover which control event occurred.
So you have to create a target action for each event.
Topic:
UI Frameworks
SubTopic:
UIKit
Tags: