码迷,mamicode.com
首页 > 其他好文 > 详细

检测麦克风是否被开启? 没开启的 调用录音功能就提示一次

时间:2015-04-20 13:07:04      阅读:185      评论:0      收藏:0      [点我收藏+]

标签:

技术分享

 

if ([[AVAudioSession sharedInstance] respondsToSelector:@selector(requestRecordPermission:)]) {
[[AVAudioSession sharedInstance] performSelector:@selector(requestRecordPermission:) withObject:^(BOOL granted) {
if (granted) {
// Microphone enabled code
NSLog(@"Microphone is enabled..");
}
else {
// Microphone disabled code
NSLog(@"Microphone is disabled..");

// We‘re in a background thread here, so jump to main thread to do UI work.
dispatch_async(dispatch_get_main_queue(), ^{
[[[[UIAlertView alloc] initWithTitle:@"Microphone Access Denied"
message:@"This app requires access to your device‘s Microphone.\n\nPlease enable Microphone access for this app in Settings / Privacy / Microphone"
delegate:nil
cancelButtonTitle:@"Dismiss"
otherButtonTitles:nil] autorelease] show];
});
}
}];
}

检测麦克风是否被开启? 没开启的 调用录音功能就提示一次

标签:

原文地址:http://www.cnblogs.com/Milo-CTO/p/4441196.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!