Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iPhone UISlider with two thumbs/indicators?

Is anyone aware of a version of the iPhone UISlider control with two thumbs? I need a control that will allow specifying a range of values. The UISlider API docs would imply this isn't possible with the standard control, so I was wondering if anyone had a solution for this (or had solved it themselves).

like image 996
Chris W. Avatar asked Feb 02 '10 13:02

Chris W.


3 Answers

Here's a range slider I just cooked up

http://github.com/cmezak/CMRangeSlider

like image 184
CharlieMezak Avatar answered Oct 31 '22 08:10

CharlieMezak


If you're still interested this is my implementation. I'm making it well documented so everyone could start using it with ease.

https://github.com/fcy/fancy-ios/tree/master/src/ui/range-slider

It works with iOS 5+

like image 26
Felipe Cypriano Avatar answered Oct 31 '22 07:10

Felipe Cypriano


I had this problem too. The way I solved it was a bit of a hack but simpler for noobs like me!

I put two sliders on top of eachother. Made the track of one invisible using a transparent .png file. Then created a sliderReleased: method that I linked to the touch up inside event in interface builder that switches the userInteractionEnabled: state of each slider.

It means that you can only set one slider at a time and you have to touch one before you can set the other but for my purposes it does the job.

I linked both sliders' touch up inside to this method and set tags to 1 and 2 and linked the value changed event to individual methods like normal.

-(IBAction) onReleaseBP: (id) sender {
if ([sender tag]==1) {
    [diastolicSld setUserInteractionEnabled:NO];
    [systolicSld setUserInteractionEnabled:YES];     
}
else {
    [systolicSld setUserInteractionEnabled:NO];
    [diastolicSld setUserInteractionEnabled:YES];
}
like image 42
Jon Avatar answered Oct 31 '22 06:10

Jon