uikituicontroluicontroleventstarget-action

How do I set primaryActionTriggered for a custom UIControl?


I've created a custom UIControl. The closest comparison is a UIStepper but it is a subclass of UIControl because its wholly custom.

For most UIControls you can create target actions with primaryActionTriggered to avoid needing to know which action matters. I want the same convenience for my custom UIControl. So how do I map UIControl.Event.valueChanged to UIControl.Event.primaryActionTriggered?


Solution

  • I think if you are listening for the valueChanged event then you just need to manually call sendActions(for: .primaryActionTriggered) when that event fires