Search code examples
iphoneiosuislider

How to show value of UISlider as Integer


The value of the UISlider currently shows as a float. How do I show it as an integer?

sliderCtl = [[UISlider alloc] initWithFrame:frame];
    sliderCtl.minimumValue = 1;
    sliderCtl.maximumValue = 15;
    sliderCtl.continuous = NO;
    sliderCtl.value = 1;
    [sliderCtl setShowValue:YES];

Solution

  • You could truncate or round the value from the slider and then update it to give the user feedback about the change (it would appear to snap to the integer value when the user releases).