我正在开发一款需要显示运行时间码时钟的iPhone / iPad应用程序.我已经让它显示正确的小时,分钟和秒,使用此代码没有问题:
- (void) viewDidLoad { // Start the Timer method for here to start it when the view loads. runTimer = [NSTimer scheduledTimerWithTimeInterval: .01 target: self selector: @selector(updatedisplay) userInfo: nil repeats: YES]; } - (void)updatedisplay { NSDateFormatter *formatter = [[NSDateFormatter alloc] init]; NSDate *date = [NSDate date]; // display each hour,minute,second and frame. [formatter setDateFormat:@"hh"]; [timecodeHourLabel setText:[formatter stringFromDate:date]]; [formatter setDateFormat:@"mm"]; [timecodeMinuteLabel setText:[formatter stringFromDate:date]]; [formatter setDateFormat:@"ss"]; [timecodeSecondLabel setText:[formatter stringFromDate:date]]; }
问题是我需要每秒显示帧数.我知道计算1/24 * 1000会给我一帧中的毫秒数.我只是不知道如何使NSDate和NSTimer函数与此代码一起使用,并允许它根据运行时间码的需要尽快更新UILabel.
有什么建议?
解决方法
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。