您的位置:首页 > 移动开发 > IOS开发

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;  

    }  

}  
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: