Search code examples
iphoneiosobjective-ccocoa-touchuislider

Move UISlider directly to a value


I have a UISlider with values from 0 to 5. I want the thumb to stop only at the exact values and not in between. Is moving the slider programmatically the only option? Or is there a property which governs this behavior?


Solution

  • Use function round to get the value from the slider

    NSInteger value = (NSInteger)round(slider.value);
    NSLog(@"Slider value is %d", value);