How to read each UISlider value no matter how fast the slider moves?

I need to read every value of a UISlider . When I print the value of the slider in the debug area, you will see that each value increases by 1 when you move the slider at a slow average pace.

Slider values ​​at slow-medium pace

However, when I move the slider quickly, the values ​​jump in large steps, as shown below:

Slider values ​​at fast pace

In any case, can I read the value of the slider with each step, regardless of its speed? (preferably fast)

code:

 @IBAction func didMoveFeedbackSlider(sender: UISlider) { let currentValue = sender.value var currentValueInt = Int(ceil(currentValue)) print("slider value: \(currentValueInt)") } 
+5
source share
1 answer

OK, if you want to follow your algorithm, this is a possible solution

 var value:Int = 0 func readSliderValue(val:Int) { while(value != val) { value = value + (val < value ? -1 : 1) // or use += print(value) } } 

But Matt is probably right, and the problem is in the design and / or algorithm.

Why the values ​​are not consistent: the slider represents the actual value of the slider using the mouse / finger position. When you move your finger very fast, like in your video / gif, the internal process that scans your position / gesture of your finger is slower than your finger. Thus, between two checks of internal algorithms for determining the position of the finger (finger), more than one position of the slider intersects. Thus, the idea of ​​a slider is not to show you how your finger went, but where it is now. Thus, the slider works correctly, perspectives are created from it :)

+6
source

All Articles