• ios 查询相册/摄像头/麦克风 的使用权限



    www.MyException.Cn  网友分享于:2015-06-21  浏览:0次
     
     
    iOS如何判断应用是否开启摄像头权限

    AVAuthorizationStatus authStatus = [AVCaptureDevice authorizationStatusForMediaType:AVMediaTypeVideo];  

    typedef NS_ENUM(NSInteger, AVAuthorizationStatus) {

    AVAuthorizationStatusNotDetermined = 0, //点击允许访问时调用  //用户明确许可与否,媒体需要捕获,但用户尚未授予或拒绝许可。

    AVAuthorizationStatusRestricted, 

    AVAuthorizationStatusDenied,   //不允许

    AVAuthorizationStatusAuthorized   //允许访问 

    } NS_AVAILABLE_IOS(7_0);

     

    麦克风权限检测:

    1. //检测麦克风功能是否打开  
    2.   [[AVAudioSessionsharedInstance]requestRecordPermission:^(BOOL granted) {  
    3.       if (!granted)  
    4.       {  
    5.           [ViewUtilalertViewWithString:NSLocalizedString(@"麦克风功能未开启",nil)];  
    6.       }  
    7.       else  
    8.       {  
    9.             
    10.           [selfrecord:sender];  
    11.       }  
    12.   }];

    相册权限检测:需要

    #import <AssetsLibrary/AssetsLibrary.h> //导入此类和AssetsLibrary.framework框架

    1. int author = [ALAssetsLibrary authorizationStatus];  
    2.             NSLog(@"author type:%d",author);  
    3.             if(author == ALAuthorizationStatusRestricted || author == ALAuthorizationStatusDenied) {  
    4.                 // The user has explicitly denied permission for media capture.  
    5.                 UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"无法使用相册"  
    6.                                                                 message:@"请在iPhone的"设置-隐私-照片"中允许访问照片。"  
    7.                                                                delegate:self  
    8.                                                       cancelButtonTitle:@"确定"  
    9.                                                       otherButtonTitles:nil];  
    10.                 [alert show];  
    11.                 [alert release];  
    12.                 return;
  • 相关阅读:
    css 文本超过指定行数,显示省略号
    CSS 使radio和checkbox框,和文字对齐平行
    C# 使用InputStream接收 解析表单参数
    CSS 控制文本超出宽度,显示省略号
    C# 将http在线文件,保存到服务器指定位置
    C# Get请求
    C# POST请求
    js 使用XMLHttpRequest 上传文件,显示进度条
    js 验证字符长度,一个中文2个字符,英文和数字为1个字符
    iOS Carthage集成SnapKit
  • 原文地址:https://www.cnblogs.com/blogfantasy/p/5213276.html
Copyright © 2020-2023  润新知