使用NSTimer可以显示每秒的时间码帧
|
我正在使用需要显示运行时间码时钟的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
。
有什么建议么?
没有找到相关结果
已邀请:
2 个回复
涸坍饺
郡豪靠暖