美文网首页
iOS9之后获取相册 相机权限

iOS9之后获取相册 相机权限

作者: 41c48b8df394 | 来源:发表于2018-07-25 16:28 被阅读28次

获取相册权限

 PHAuthorizationStatus status =  [PHPhotoLibrary authorizationStatus];
    if (status == PHAuthorizationStatusRestricted || status == PHAuthorizationStatusDenied) {
        UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"温馨提示" message:@"请您先去设置允许APP访问您的相册 设置>隐私>相册" preferredStyle:(UIAlertControllerStyleAlert)];
        UIAlertAction *action = [UIAlertAction actionWithTitle:@"我知道了" style:(UIAlertActionStyleDefault) handler:^(UIAlertAction * _Nonnull action) {
            
        }];
        [alertController addAction:action];
        [self presentViewController:alertController animated:YES completion:nil];
    }

获取相机权限
需要导入框架
#import <AVFoundation/AVCaptureDevice.h>

AVAuthorizationStatus status = [AVCaptureDevice authorizationStatusForMediaType:( AVMediaTypeVideo)];
    
    if (status == AVAuthorizationStatusRestricted || status == AVAuthorizationStatusDenied) {
        UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"温馨提示" message:@"请您先去设置允许金桐访问您的相机 设置>隐私>相机>金桐" preferredStyle:(UIAlertControllerStyleAlert)];
        UIAlertAction *action = [UIAlertAction actionWithTitle:@"我知道了" style:(UIAlertActionStyleDefault) handler:^(UIAlertAction * _Nonnull action) {
            
        }];
        [alertController addAction:action];
        [self presentViewController:alertController animated:YES completion:nil];
        return;
    }

相关文章

网友评论

      本文标题:iOS9之后获取相册 相机权限

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