判断相机权限

论坛 期权论坛 编程之家     
选择匿名的用户   2021-6-2 16:40   1682   0
#pragma mark - 相机权限
-(BOOL)camaraEnable;
{
AVAuthorizationStatus authStatus = [AVCaptureDevice authorizationStatusForMediaType:AVMediaTypeVideo];

if (authStatus == AVAuthorizationStatusDenied) {

if (IOS8_OR_LATER) {

UIAlertView *alert=[[UIAlertView alloc] initWithTitle:@"相机被禁用"
message:@"请在iPhone的“设置-隐私-相机”中允许**访问您的相机。"
delegate:self
cancelButtonTitle:@"取消"
otherButtonTitles:@"设置", nil];
alert.tag = 800;

[alert show];

} else {

UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"相机被禁用"
message:@"请在iPhone的“设置-隐私-相机”中允许**访问您的相机。"
delegate:nil
cancelButtonTitle:@"确定"
otherButtonTitles:nil, nil];
[alert show];
}

return NO;

} else {

//允许了
if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) {

return YES;

} else {

MyNSLog("设备不支持摄像头");

return NO;
}
}
}
分享到 :
0 人收藏
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

积分:3875789
帖子:775174
精华:0
期权论坛 期权论坛
发布
内容

下载期权论坛手机APP