Quote:
Originally Posted by jjardim
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
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
|
Just wanted to contribute back - here is what I did
int timerInt = (int)mySlider.value;
lblSliderValue.text = [NSString stringWithFormat:@"%02d:%02d", timerInt / 60, timerInt % 60];
I converted the UISlider properties to Seconds in IB