iOS 麦克风访问权限
2016-01-08 16:43
274 查看
- (BOOL)canRecord
{
__block BOOL bCanRecord = YES;
if ([[[UIDevice currentDevice] systemVersion] compare:@"7.0"] != NSOrderedAscending)
{
AVAudioSession *audioSession = [AVAudioSession sharedInstance];
if ([audioSession respondsToSelector:@selector(requestRecordPermission:)]) {
[audioSession performSelector:@selector(requestRecordPermission:) withObject:^(BOOL granted) {
if (granted) {
bCanRecord = YES;
} else {
bCanRecord = NO;
}
}];
}
}
return bCanRecord;
}
#pragma mark - Audio Recorder √
/*开始录音*/
- (void)startToRecord:(id)sender
{
if (![self canRecord]) {
[[[UIAlertView alloc] initWithTitle:nil
message:[NSString stringWithFormat:@"%@需要访问您的麦克风。\n请启用麦克风-设置/隐私/麦克风", [TIXAAppMonitor sharedMonitor].appName]
delegate:nil
cancelButtonTitle:@"好"
otherButtonTitles:nil] show];
return;
}
}
{
__block BOOL bCanRecord = YES;
if ([[[UIDevice currentDevice] systemVersion] compare:@"7.0"] != NSOrderedAscending)
{
AVAudioSession *audioSession = [AVAudioSession sharedInstance];
if ([audioSession respondsToSelector:@selector(requestRecordPermission:)]) {
[audioSession performSelector:@selector(requestRecordPermission:) withObject:^(BOOL granted) {
if (granted) {
bCanRecord = YES;
} else {
bCanRecord = NO;
}
}];
}
}
return bCanRecord;
}
#pragma mark - Audio Recorder √
/*开始录音*/
- (void)startToRecord:(id)sender
{
if (![self canRecord]) {
[[[UIAlertView alloc] initWithTitle:nil
message:[NSString stringWithFormat:@"%@需要访问您的麦克风。\n请启用麦克风-设置/隐私/麦克风", [TIXAAppMonitor sharedMonitor].appName]
delegate:nil
cancelButtonTitle:@"好"
otherButtonTitles:nil] show];
return;
}
}
相关文章推荐
- iOS tabbar 图片尺寸
- IOS8键盘模拟器无法显示,真机可以
- 坐标系转换 iOS
- iOS - 线程管理
- js调用Android、ios原生代码
- iOS中NSDictionary和NSMutableDictionary的用法
- iOS 记录系统运行日志到指定文件目录
- iOS开发拓展篇—音效的播放
- iOS真机调试打印并保存控制台输出日志
- FFmpeg在iOS上完美编译
- iOS_正则表达式判断手机型号、邮箱、手机号、身份证、昵称、密码等
- iOS开发答疑
- 简单的照片查看浏览
- 图形库Core Plot
- iOS调试技巧
- iOS序列化之json(待总结。。。)
- Masonry布局框架的使用
- iOS 使cell的分割线显示完全
- Masonry的使用 ---关于AutoLayout的框架
- iOS 改变storyboard默认ViewController大小