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

jjardim

macrumors newbie
Original poster
Mar 19, 2008
26
0
I'm trying to use a UISlider to act as a Time limit. Problem is that the values go to .99 before flipping to 1.

My code so far is

Code:
int _min = (int)mySlider.value;
NSLog(@"Slider Int Minutes %i",_min);
	
NSString *str = [NSString stringWithFormat:@"%.02f",mySlider.value];
int stringLength = [str length];
NSRange range = NSMakeRange(0, stringLength);
NSString *newStr = [str stringByReplacingOccurrencesOfString:@"." withString:@":" options:NSCaseInsensitiveSearch range:range];
	
NSLog(@"Old String: '%@' --> New String: '%@'", str, newStr);


So the slider works, but I would like once the decimal place hits .60 it increases by 1 and resets the decimals to .00

Screenshot Attached.

Thanks,
Jason Jardim
 

Attachments

  • Screen shot 2010-01-14 at 10.33.42 AM.png
    Screen shot 2010-01-14 at 10.33.42 AM.png
    30.1 KB · Views: 264
I'm gonna suggest you just set the max value of your slider to the amount of time you want in seconds and then just convert the current slider value from the float into minutes & seconds.
 
Found my solution

Just wanted to contribute back - here is what I did

Code:
int timerInt = (int)mySlider.value;
	
lblSliderValue.text = [NSString stringWithFormat:@"%02d:%02d", timerInt / 60, timerInt % 60];

I converted the UISlider properties to Seconds in IB
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.