plist文件中权限已配置,Privacy - Camera Usage Description,iOS 12以下没问题,但是在iOS 12 beta 的时候就闪退
//判断是否已授权
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7.0) {
AVAuthorizationStatus authStatus = [AVCaptureDevice authorizationStatusForMediaType:AVMediaTypeVideo];
if (authStatus == AVAuthorizationStatusDenied||authStatus == AVAuthorizationStatusRestricted) {
[FNSystemSet gotoSetCamera:self];
return ;
}
}
//获取相机权限
[AVCaptureDevice requestAccessForMediaType:AVMediaTypeVideo completionHandler:^(BOOL granted) {
NSLog(@"%@",granted ? @"相机准许":@"相机不准许");
}];
// 判断是否可以打开相机
if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) {
[self presentViewController: [self selectPicture:UIImagePickerControllerSourceTypeCamera]
animated:YES
completion:^{
}];
} else {
FNLog(@"没有相机");
}
最终解决:是在plist文件中加入麦克风权限就OK了