Search code examples
iosswiftslideruicontrolrangeslider

How to detect when user finished moving Range slider in Swift


I use this is Range slider in my project. How use it.

I want to detect, when user finished moving Range slider. I tried to use function SliderAction(sender: RangeSlider), but I get each moving points in the slider. I think I need to use this function: func endTrackingWithTouch(touch: UITouch?, withEvent event: UIEvent?), but it is doesn't work. How can I make it?


Solution

  • To detect when user finished moving the range slider you can add a controlevent to your slider , you can add it programatically :

    mySlider.addTarget(self, action: "sliderDidEndSliding:", forControlEvents: .UIControlEventTouchUpInside)
    

    then you have to do your logic the recieving methode .

        func sliderDidEndSliding(sender: UISlider) {
    }