plist文件中權(quán)限已配置,Privacy - Camera Usage Description,iOS 12以下沒問(wèn)題,但是在iOS 12 beta 的時(shí)候就閃退
//判斷是否已授權(quán)
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7.0) {
AVAuthorizationStatus authStatus = [AVCaptureDevice authorizationStatusForMediaType:AVMediaTypeVideo];
if (authStatus == AVAuthorizationStatusDenied||authStatus == AVAuthorizationStatusRestricted) {
[FNSystemSet gotoSetCamera:self];
return ;
}
}
//獲取相機(jī)權(quán)限
[AVCaptureDevice requestAccessForMediaType:AVMediaTypeVideo completionHandler:^(BOOL granted) {
NSLog(@"%@",granted ? @"相機(jī)準(zhǔn)許":@"相機(jī)不準(zhǔn)許");
}];
// 判斷是否可以打開相機(jī)
if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) {
[self presentViewController: [self selectPicture:UIImagePickerControllerSourceTypeCamera]
animated:YES
completion:^{
}];
} else {
FNLog(@"沒有相機(jī)");
}
最終解決:是在plist文件中加入麥克風(fēng)權(quán)限就OK了