Skip to content

API improvement: UIControl.AddTarget #4598

@migueldeicaza

Description

@migueldeicaza

The binding that we provide today to UIControl.AddTarget is hardcoded to one of the potential method signatures. AddTarget nowadays (or maybe always) supported a vaster set of callbacks, and the actual method invoked today depends on the signature of the selector:

https://developer.apple.com/documentation/uikit/uicontrol#1943645

These are:

@IBAction func doSomething()
@IBAction func doSomething(sender: UIButton)
@IBAction func doSomething(sender: UIButton, forEvent event: UIEvent)

Today, we only support the first kind, we would need to extend our API to take delegates that take a <UIControl> and a <UIControl,UIEvent> to handle those scenarios.

Today, a workaround I used was this:

slider.AddTarget (this, new ObjCRuntime.Selector ("slider:event:"), UIControlEvent.ValueChanged);
...
[Export ("slider:event:")]
void SliderMovedEvent (UISlider senderSlider, UIEvent uievent)

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementThe issue or pull request is an enhancementiOSIssues affecting iOS

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions