///新增api,获取录音权限. 返回值,YES为无拒绝,NO为拒绝录音. - (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; } }
ios7-录音权限访问-AVAudioSession
猜你喜欢
转载自lizaochengwen.iteye.com/blog/1975788
今日推荐
周排行