views:

77

answers:

1

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

+1  A: 

I would suggest not fussing with the slider - let it measure decimal minutes, then convert to MM:SS for display.

For example: if the slider would display 1:30, the actual output of mySlider.value is 1.5.

CajunLuke