0

我正在尝试使用 UISlider 作为时间限制。问题是值在翻转到 1 之前变为 0.99。

到目前为止我的代码是

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);

所以滑块可以工作,但我想一旦小数位达到 0.60,它就会增加 1 并将小数重置为 .00

附上截图。

谢谢,杰森贾丁

4

1 回答 1

1

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.

于 2010-01-14T16:32:02.983 回答