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
2010-03-25 21:32:44
Thanks works like a charm!
Tyler29294
2010-03-26 18:29:46
Good. If it works like a charm, you could consider accepting my answer.
Tuomas Pelkonen
2010-03-26 19:12:57