Pregunta

I'm using AVAudioRecorder to record from iPhone, and I have a UILabel to keep track of the current recording time of my AVRecorder. So I set the UILabel text with AVRecorder.currentTime and with this format: %.02f I show me the current time like this: "39.02"

The problem is the last digit after the dot does not updating with current time, it's only updated when I pause the recording. Maybe something like this:

Recording: "39.01" -> "39.11" -> "39.41" (the last digit was not updated) Paused: "39.48" (the last digit was updated)

It seems like the millisecond digit been updating to fast and the UILabel could not keep track of it. Or is there something I have to do with Rounding a float?

¿Fue útil?

Solución

Make sure you call your update method every 0.01 second :

[NSTimer scheduledTimerWithTimeInterval: 0.01 
                                 target: self
                               selector: @selector(updateLabel)
                               userInfo: nil
                                repeats: YES];
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top