• iOS权限问题


    判断相机权限:

    NSString *mediaType = AVMediaTypeVideo;
    AVAuthorizationStatus authStatus = [AVCaptureDevice authorizationStatusForMediaType:mediaType];
    if(authStatus == AVAuthorizationStatusRestricted || authStatus == AVAuthorizationStatusDenied){
                       //相机权限受限制
    }
    typedef NS_ENUM(NSInteger, AVAuthorizationStatus) {
        AVAuthorizationStatusNotDetermined = 0,    请问是否授权访问
        AVAuthorizationStatusRestricted,     权限都限制
        AVAuthorizationStatusDenied,    拒绝访问
        AVAuthorizationStatusAuthorized     授权访问
    } NS_AVAILABLE_IOS(7_0) __TVOS_PROHIBITED;

    判断相册权限:

    if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 8.0){
    PHAuthorizationStatus status = [PHPhotoLibrary authorizationStatus];
        if (status == PHAuthorizationStatusDenied || status == PHAuthorizationStatusRestricted) {
            //相册权限受限制
        }
    }
    else{
        ALAuthorizationStatus status = [ALAssetsLibrary authorizationStatus];
        if (status == ALAuthorizationStatusDenied || status == ALAuthorizationStatusRestricted) {
             //相册权限受限制
        }
    }

    ALAuthorizationStatus 在iOS9之后废弃了,
    PHAuthorizationStatus 是ios8新增的替代 ALAuthorizationStatus 的方法。
    typedef NS_ENUM(NSInteger, PHAuthorizationStatus) {
        PHAuthorizationStatusNotDetermined = 0, 
        PHAuthorizationStatusRestricted,       
        PHAuthorizationStatusDenied,        
        PHAuthorizationStatusAuthorized        
    } NS_AVAILABLE_IOS(8_0);
    typedef NS_ENUM(NSInteger, ALAuthorizationStatus) {
        ALAuthorizationStatusNotDetermined 
        ALAuthorizationStatusRestricted 
        ALAuthorizationStatusDenied 
        ALAuthorizationStatusAuthorized 
    } NS_DEPRECATED_IOS(6_0, 9_0, "Use PHAuthorizationStatus in the Photos framework instead");
  • 相关阅读:
    P1012 拼数(水题)
    oracle 存储过程中调用同义词报错“表和视图不存在”
    C#文件相对路径
    C# WebAPi接收和发送图片
    EFCore学习笔记一:(安装EFCore并根据Code First生成数据库)
    Winform切换登录用户
    Winform中子控件Dock排列顺序问题
    ORA-28001: the password has expired解决方法
    C#实体类生成XML(注意<![CDATA]>标签的不解析)
    一次完整的HTTP请求过程
  • 原文地址:https://www.cnblogs.com/huahua0809/p/5293098.html
Copyright © 2020-2023  润新知