美文网首页
提示开启相册权限

提示开启相册权限

作者: MMOTE | 来源:发表于2019-11-26 15:43 被阅读0次
//相册权限
    PHAuthorizationStatus status = [PHPhotoLibrary authorizationStatus];
    if (status != PHAuthorizationStatusAuthorized) {
        [PHPhotoLibrary requestAuthorization:^(PHAuthorizationStatus status) {
            if(status == PHAuthorizationStatusAuthorized) {
                dispatch_async(dispatch_get_main_queue(), ^{
                    // 用户点击 "OK"
                    
                });
            } else {
                dispatch_async(dispatch_get_main_queue(), ^{
                    // 用户点击 不允许访问
                    UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"提示" message:@"请前往“设置-APP名字-照片”开启权限" preferredStyle:UIAlertControllerStyleAlert];
                    [alert addAction:[UIAlertAction actionWithTitle:@"好的呢" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
                        
                    }]];
                    alert.modalPresentationStyle = UIModalPresentationFullScreen;
                    [self presentViewController:alert animated:YES completion:nil];
                    return;
                });
            }
        }];
    }else {
        // 已获得权限
        
    }

相关文章

网友评论

      本文标题:提示开启相册权限

      本文链接:https://www.haomeiwen.com/subject/kitywctx.html