我正在开发一个QuiZ应用程序.它需要一个倒数计时器,因为我想在75:00.00(mm:ss.SS)启动计时器,并通过减少1毫秒将其减少到00:00.00(mm:ss.SS).我想显示Time Up的警报!当时间到达00:00.00(mm:ss.SS).
我通过以下链接显示时间
我正在使用以下代码显示时间...我在viewController中有滚动视图...这里我显示的时间从00:00.00开始(mm:ss:SS)(分钟:秒:毫秒)并且目标是递增毫秒,秒基于毫秒,基于秒的分钟...但我想显示从75:00.00(mm:ss:SS)开始的时间,我想将毫秒,秒和分钟减少到00:00.00(mm:ss) .SS)......我怎么能......?
我在以下链接中已经在SO中询问过这个问题.NSTimer以秒/毫秒减少时间
我按照那段代码时间不计算(在后台也是)当我拖动并按住滚动视图而不释放鼠标点击...帮我修改下面的代码...
enter code here
@interface ViewController : UIViewController
{
IBOutlet UILabel *time;
NSTimer *stopWatchTimer;
NSDate *startDate;
NSTimeInterval secondsAlreadyRun;
}
- (void)reset:(id)sender;
- (void)onStartPressed:(id)sender;
- (void)onStopPressed:(id)sender;
enter code here
-(void)showActivity:(NSTimer *)tim
{
NSDate *currentDate = [NSDate date];
NSTimeInterval timeInterval = [currentDate timeIntervalSinceDate:startDate];
// Add the saved interval
timeInterval += secondsAlreadyRun;
NSDate *timerDate = [NSDate dateWithTimeIntervalSince1970:timeInterval];
static NSDateFormatter * dateFormatter = nil;
if( !dateFormatter ){
dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"mm:ss.SS"];
[dateFormatter setTimeZone:[NSTimeZone timeZoneForSecondsFromGMT:0.0]];
}
NSString *timeString=[dateFormatter …
Run Code Online (Sandbox Code Playgroud)