Using Xcode 5.0 and running iOS 7.0.2 on my device.

I am using this kind of code:

AVAudioRecorder *audioRecorder;
………
[audioRecorder recordForDuration:(NSTimeInterval)5.0];
………
- (void)audioRecorderDidFinishRecording:(AVAudioRecorder *)recorder successfully:(BOOL)flag
{
        NSLog(@"audioRecorderDidFinishRecording");
}

On the simulator things are OK the method audioRecorderDidFinishRecording fires up as expected 5 seconds after a call to recordForDuration has been made. On the device though it never fires up. Why could that happen? Any idea?

I have seen similar questions on the net, but not exactly this one and more important no answer that worked for me.

有帮助吗?

解决方案

In case someone else has the same issue. Here is the solution I found:

One needs the following before calling the recordForDuration method.

[[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayAndRecord error:nil];

Strangely enough this is not an issue on the simulator.

其他提示

audioRecorder.stop() needs to be called as well

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top