Reputation: 132
I have a view controller with 3 sliders. I only have 1 function that needs to be called every time a slider value changes - a value change in any one of the 3 sliders should cause call to that function.
How do i do that?
If I try to use outlets then I am only able to link only one UISlider.
Upvotes: 0
Views: 637
Reputation: 124997
If I try to use outlets then I am only able to link one UISlider.
You need to connect the slider to a target and action, not an outlet. The target is the object that will receive a message when the slider changes, and the action is the message that will be sent to the target. An outlet, on the other hand, is a reference to some object; for example, if you connect a slider to an outlet in your view controller, the view controller will then have a reference to the slider that it can use to send messages to the slider.
Upvotes: 1
Reputation: 57114
You can simply connect the Value changed
event of all sliders to the same IBAction
:
If you want to connect them as outlets (which is something entirely different) you will have to use an IBOutletCollection
:
Upvotes: 2