View Full Version : UISlider snapping
Duke Leto
Jan 27, 2009, 11:27 PM
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
Jan 28, 2009, 06:08 AM
Not to my knowledge. Class ref is here (https://developer.apple.com/iphone/library/documentation/UIKit/Reference/UISlider_Class/Reference/Reference.html), I guess you could hack thumbRectForBounds to make it look like it's snapping to discrete values, though it's a nasty kludge...
dejo
Jan 28, 2009, 10:06 AM
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):
if (slider.value >= 0.5) {
slider.value = 1.0;
genderCode = @"F";
} else {
slider.value = 0.0;
genderCode = @"M";
}
vBulletin® v3.8.6, Copyright ©2000-2012, Jelsoft Enterprises Ltd.