소스 검색

1.代码暂存

huangxiaodong 8 달 전
부모
커밋
d4d5d93524

+ 30 - 1
创维盒子/双子星云手机/Class/Set/uploadFile/uploadImageOrVideoViewController.m

@@ -234,8 +234,11 @@
                     [self.photoGroupView setupGroup];
                     [self delayedSetPhotoGroupViewFrameFun];
                 });
-                
             }
+          else if (status == PHAuthorizationStatusDenied || status == PHAuthorizationStatusRestricted) {
+              // 用户拒绝授权或设备受限,提示用户去系统设置中开启权限
+              [self requestPhotoLibraryAccessWithAlert];
+           }
         }];
     }
 }
@@ -765,4 +768,30 @@
     
 }
 
+#pragma mark 用户拒接授权相册
+- (void)requestPhotoLibraryAccessWithAlert {
+    UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"相册访问被拒绝"
+                                                                   message:@"为了正常使用应用功能,请允许访问您的相册。"
+                                                            preferredStyle:UIAlertControllerStyleAlert];
+      
+    UIAlertAction *settingsAction = [UIAlertAction actionWithTitle:@"去设置"
+                                                            style:UIAlertActionStyleDefault
+                                                          handler:^(UIAlertAction *action) {
+                                                              // 打开应用的设置页面
+                                                              NSURL *url = [NSURL URLWithString:UIApplicationOpenSettingsURLString];
+                                                              if ([[UIApplication sharedApplication] canOpenURL:url]) {
+                                                                  [[UIApplication sharedApplication] openURL:url options:@{} completionHandler:nil];
+                                                              }
+                                                          }];
+      
+    UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"取消"
+                                                           style:UIAlertActionStyleCancel
+                                                         handler:nil];
+      
+    [alert addAction:settingsAction];
+    [alert addAction:cancelAction];
+      
+    [self presentViewController:alert animated:YES completion:nil];
+}
+
 @end

+ 2 - 1
创维盒子/双子星云手机/zh-Hans.lproj/Localizable.strings

@@ -619,4 +619,5 @@
 "sn_copy_suc" = "SN复制成功";
 "disk_space_not_tip_for_95"   = "可用容量已达到95%,继续上传会导致云机无法操";
 "disk_space_not_tip_for_95_fail_tip"   = "磁盘空间不足";
-
+"enable_photo_permission"   = "开启照片权限";
+"enable_photo_permission_tip"   = "照片权限被禁用,允许访问所有照片可以享受更好的上传服务,过程加密安全请放心。";