美文网首页
iOS-请求系统麦克风(话筒)的方法

iOS-请求系统麦克风(话筒)的方法

作者: 漂泊的飞鸟 | 来源:发表于2016-12-30 17:56 被阅读0次

- (void)noCanRecorded{

UIAlertController*alterC = [UIAlertControlleralertControllerWithTitle:@"麦克风被禁用"message:@"您可点击去设置,开启麦克风权限"preferredStyle:UIAlertControllerStyleAlert];

UIAlertAction*gotoSetting = [UIAlertActionactionWithTitle:@"去设置"style:UIAlertActionStyleDestructivehandler:^(UIAlertAction*_Nonnullaction) {

if(kSYSTEM_VERSION_LESS_THAN(@"10")) {

NSURL*url= [NSURLURLWithString:@"prefs:root=Privacy&path=MICROPHONE"];

if([[UIApplicationsharedApplication]canOpenURL:url]) {

[[UIApplicationsharedApplication]openURL:url];

}

}else{

NSURL*url = [NSURLURLWithString:UIApplicationOpenSettingsURLString];

if([[UIApplicationsharedApplication]canOpenURL:url]) {

[[UIApplicationsharedApplication]openURL:urloptions:@{}completionHandler:^(BOOLsuccess) {

}];

}

}

}];

UIAlertAction*cancel = [UIAlertActionactionWithTitle:@"知道了"style:UIAlertActionStyleCancelhandler:^(UIAlertAction*_Nonnullaction) {

}];

[alterCaddAction:gotoSetting];

[alterCaddAction:cancel];

[selfpresentViewController:alterCanimated:YEScompletion:nil];

}

相关文章

网友评论

      本文标题:iOS-请求系统麦克风(话筒)的方法

      本文链接:https://www.haomeiwen.com/subject/rcnmvttx.html