我在录制应用程序中添加 uiprogreesView。当我点击开始录制按钮时,开始录制需要几秒钟,我的进度视图开始,我还管理 uilabels 来获取录制的时间。但是我的进度视图与录制时间不同步。实际录制时间少于进度视图标签..这是我的代码
- (IBAction)startRecordingButtonPressed:(id)sender {
recorder = [[AVAudioRecorder alloc]initWithURL:recordedFile
settings:recordSetting error:&error];
[recorder setDelegate:self];
[recorder prepareToRecord];
[recorder recordForDuration:(NSTimeInterval)60];
[recorder record];
timeStartLabel.text != "0";
progressView.progress = 0.0;
[NSThread detachNewThreadSelector:@selector(startjob)
toTarget:self withObject:nil];
}
- (void )startjob {
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc]init];
[NSThread sleepForTimeInterval:2];
[self performSelectorOnMainThread:@selector(moreProgress)
withObject:nil waitUntilDone:NO];
[pool release];
}
- (void)moreProgress {
float actual = [progressView progress];
timeStartLabel.text = [NSString stringWithFormat:@"%.2f" ,actual];
if (actual < 1) {
progressView.progress = actual + 0.01;
[NSTimer scheduledTimerWithTimeInterval:0.5
target:self
selector:@selector(moreProgress)
userInfo:nil repeats:NO];
}
}
请帮助。当我点击录制按钮时,按钮将变为蓝色几秒钟,然后我回到其默认颜色,然后开始实际录制,但在点击按钮时开始进度视图。