tags:

views:

221

answers:

1

How do have my UISlider go from 1-100 by going by 5s?

+4  A: 

Add a delegate like this:

slider.continuous = YES;
[slider addTarget:self
      action:@selector(valueChanged:) 
      forControlEvents:UIControlEventValueChanged];

And in the valueChanged function set the value to the closest value that is divisible by 5.

[slider setValue:((int)((slider.value + 2.5) / 5) * 5) animated:NO];
Tuomas Pelkonen
Thanks works like a charm!
Tyler29294
Good. If it works like a charm, you could consider accepting my answer.
Tuomas Pelkonen