Eugene Zhenya Gordin Eugene Zhenya Gordin - 1 year ago 78
iOS Question

iOS: Get the final value of UISlider after user releases the finger

In my iOS app (8.1). I have a UISlider which continuous property is set to YES (because I need to update labels dynamically).

My problem is that I also need to send the value picked and send it to the server. So in my case right now it does it all the time.

Can I somehow get only the last value? The value after the user releases the finger?

Any kind of help is highly appreciated.

P.S. I looked through a lot of solutions on Stackoverflow, like touchesBegan/ended, linking events in the NIB but nothing works so far.

Answer Source

Yu can connect multiple actions to a single control, including a slider. In addition to the one you have for "value changed", create another method hooked up to "touch up inside", and grab the slider's value in that method.

- (IBAction)dragged:(UISlider *)sender { // value changed
    // update labels continuously here

- (IBAction)endedDragging:(UISlider *)sender { // touch up inside
    NSLog(@"value is %f",sender.value);
    //grab the final value here
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download