|
@@ -231,12 +231,45 @@
|
|
|
|
|
|
|
|
} else {
|
|
} else {
|
|
|
__weak typeof(self) weakself = self;
|
|
__weak typeof(self) weakself = self;
|
|
|
- UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"Warning" message:@"Camera access denied, please change iPad setting, allow App use camara. (setting -> privacy -> camera enable RA Image)" preferredStyle:UIAlertControllerStyleAlert];
|
|
|
|
|
- UIAlertAction *action = [UIAlertAction actionWithTitle:@"Ok" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
|
|
|
|
|
- [weakself dismissViewControllerAnimated:YES completion:nil];
|
|
|
|
|
- }];
|
|
|
|
|
- [alert addAction:action];
|
|
|
|
|
- [self presentViewController:alert animated:YES completion:nil];
|
|
|
|
|
|
|
+// UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"Warning" message:@"Camera access denied, please change iPad setting, allow App use camara. (setting -> privacy -> camera enable RA Image)" preferredStyle:UIAlertControllerStyleAlert];
|
|
|
|
|
+// UIAlertAction *action = [UIAlertAction actionWithTitle:@"Ok" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
|
|
|
|
|
+// [weakself dismissViewControllerAnimated:YES completion:nil];
|
|
|
|
|
+// }];
|
|
|
|
|
+// [alert addAction:action];
|
|
|
|
|
+// [self presentViewController:alert animated:YES completion:nil];
|
|
|
|
|
+
|
|
|
|
|
+ if (![UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) { // 设备不可用
|
|
|
|
|
+ UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"Warning" message:@"Camera is not available" preferredStyle:UIAlertControllerStyleAlert];
|
|
|
|
|
+ UIAlertAction *action = [UIAlertAction actionWithTitle:@"Ok" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
|
|
|
|
|
+ [weakself dismissViewControllerAnimated:YES completion:nil];
|
|
|
|
|
+ }];
|
|
|
|
|
+ [alert addAction:action];
|
|
|
|
|
+ [self presentViewController:alert animated:YES completion:nil];
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ // 相机权限
|
|
|
|
|
+ AVAuthorizationStatus authStatus = [AVCaptureDevice authorizationStatusForMediaType:AVMediaTypeVideo];
|
|
|
|
|
+ if (authStatus ==AVAuthorizationStatusRestricted ||//此应用程序没有被授权访问的照片数据。可能是家长控制权限
|
|
|
|
|
+ authStatus ==AVAuthorizationStatusDenied) //用户已经明确否认了这一照片数据的应用程序访问
|
|
|
|
|
+ {
|
|
|
|
|
+ // 无权限 引导去开启
|
|
|
|
|
+// NSURL *url = [NSURL URLWithString:UIApplicationOpenSettingsURLString];
|
|
|
|
|
+// if ([[UIApplication sharedApplication]canOpenURL:url]) {
|
|
|
|
|
+// [[UIApplication sharedApplication]openURL:url];// 打开权限后返回应用会重启
|
|
|
|
|
+// } else {
|
|
|
|
|
+ NSDictionary* infoDict =[[NSBundle mainBundle] infoDictionary];
|
|
|
|
|
+ NSString *appName = [infoDict objectForKey:@"CFBundleName"];
|
|
|
|
|
+
|
|
|
|
|
+ UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"Warning" message:[NSString stringWithFormat:@"Camera access denied, please change %@ setting, allow App use camara. (setting -> privacy -> camera enable %@)",[UIDevice currentDevice].model,appName] preferredStyle:UIAlertControllerStyleAlert];
|
|
|
|
|
+ UIAlertAction *action = [UIAlertAction actionWithTitle:@"Ok" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
|
|
|
|
|
+ [weakself dismissViewControllerAnimated:YES completion:nil];
|
|
|
|
|
+ }];
|
|
|
|
|
+ [alert addAction:action];
|
|
|
|
|
+ [self presentViewController:alert animated:YES completion:nil];
|
|
|
|
|
+// }
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
|
|
|