怎么按照hr:min:sec的格式计算时间这是我的计算器的代码:-(IBAction)start{ timer1= [NSTimer scheduledTimerWithTimeInterval:(.01) target:self selector:@selector(timepassed) userInfo:nil repeats:YES]; }-(void)timepassed{ counter++; i
来源:学生作业帮助网 编辑:六六作业网 时间:2024/11/27 00:15:24
怎么按照hr:min:sec的格式计算时间这是我的计算器的代码:-(IBAction)start{ timer1= [NSTimer scheduledTimerWithTimeInterval:(.01) target:self selector:@selector(timepassed) userInfo:nil repeats:YES]; }-(void)timepassed{ counter++; i
怎么按照hr:min:sec的格式计算时间
这是我的计算器的代码:-(IBAction)start{ timer1= [NSTimer scheduledTimerWithTimeInterval:(.01) target:self selector:@selector(timepassed) userInfo:nil repeats:YES]; }-(void)timepassed{ counter++; if(sec==60) sec=0; else sec=counter/100; if(min==60) min=0; else min=sec/60; if(hr==24) hr=0; else hr=min/60; m1++; NSString *l=[NSString stringWithFormat:@"%i:%i:%i",hr,min,sec]; [m setText:l];}有什么错误的地方么?
怎么按照hr:min:sec的格式计算时间这是我的计算器的代码:-(IBAction)start{ timer1= [NSTimer scheduledTimerWithTimeInterval:(.01) target:self selector:@selector(timepassed) userInfo:nil repeats:YES]; }-(void)timepassed{ counter++; i
-(void) timepassed{ counter++; if (counter== 60) { secs++; counter= 0; } if (secs== 60) { min++; secs= 0; } if (min== 60) { hr++; min= 0; } // Your usual output here} 查看原帖>>
求采纳