在我更新iOS 6的应用程序后,AVAudioRecorder
在设备上不起作用,并在模拟器上[soundRecorder prepareToRecord]
中崩溃。AVAudioRecorder在iOS6更新后无法工作
UPD:用后[soundRecorder record];
没有延迟有谁找到了一些修复audioRecorderDidFinishRecording:successfully:
委托方法火灾?
- (IBAction)recordSound {
AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
[appDelegate.audioPlayer stop];
appDelegate.audioPlayer = nil;
[self stopPlaying];
if (soundRecorder.recording) {
[soundRecorder stop];
soundRecorder = nil;
[timer invalidate];
timer = nil;
NSError *error;
[[AVAudioSession sharedInstance] setActive: NO error: &error];
NSLog([error localizedDescription]);
}else{
NSManagedObject *oldSound = _sight.sound;
if (oldSound != nil) {
[__managedObjectContext deleteObject:oldSound];
}
[self saveContext];
if (!soundRecorder)
{
NSError *errorAudioSession;
[[AVAudioSession sharedInstance]
setCategory: AVAudioSessionCategoryPlayAndRecord
error: &errorAudioSession];
NSLog([errorAudioSession description]);
NSDictionary *recordSettings =
@{AVFormatIDKey: @(kAudioFormatMPEG4AAC),
AVNumberOfChannelsKey: @1,
AVEncoderAudioQualityKey: @(AVAudioQualityMedium)};
NSError *error;
AVAudioRecorder *newRecorder =
[[AVAudioRecorder alloc] initWithURL: soundFileURL
settings: recordSettings
error: &error];
NSLog([error description]);
soundRecorder = newRecorder;
soundRecorder.delegate = self;
}
[soundRecorder stop];
[soundRecorder prepareToRecord];
[soundRecorder record];
timer = [NSTimer scheduledTimerWithTimeInterval:0.1f target:self selector:@selector(updateRecordStatus) userInfo:nil repeats:YES];
}
}
它在崩溃时打印什么错误? – Kevin
我现在已经检查过了,只有在Simulator中的所有异常中启用了断点才会发生崩溃,否则在没有任何错误消息的情况下它不会正常工作。 – Shmidt
P.S.一切工作正常iOS5 – Shmidt