dotnet / dotnet/macios

API improvement: UIControl.AddTarget

Open
#4,598 4 comments 0 reactions 0 assignees View on GitHub
enhancement iOS
Dominant language
C#
Stars
2.9k
Forks
576
Avg merge
2d 12h
Merged PRs (30d)
123

Description

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 `` and a `` 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)
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.