Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Duke Leto

macrumors regular
Original poster
Mar 17, 2008
166
0
Is it possible to set a UISlider to "snap" to certain values other than by checking if the value selected is near and setting the value to that?
I am capable of the code, but I do not want to waste time.
 

jnic

macrumors 6502a
Oct 24, 2008
567
0
Cambridge
Not to my knowledge. Class ref is here, I guess you could hack thumbRectForBounds to make it look like it's snapping to discrete values, though it's a nasty kludge...
 

dejo

Moderator emeritus
Sep 2, 2004
15,982
452
The Centennial State
UISlider can effectively snap by putting the right logic into the sliderChanged: method. Here's the code I used to achieve a gender (i.e. Male / Female slider):
Code:
		if (slider.value >= 0.5) {
			slider.value = 1.0;
			genderCode = @"F";
		} else {
			slider.value = 0.0;
			genderCode = @"M";
		}
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.