AI智能
改变未来

iOS获取相机、麦克风权限

判断相机权限

[code]+ (BOOL)isCameraAuthorization {NSString *mediaType = AVMediaTypeVideo;//读取媒体类型AVAuthorizationStatus authStatus = [AVCaptureDevice authorizationStatusForMediaType:mediaType];//读取设备授权状态if(authStatus == AVAuthorizationStatusRestricted || authStatus == AVAuthorizationStatusDenied || authStatus == AVAuthorizationStatusNotDetermined) {return NO;}return YES;}

请求授权

[code]    [AVCaptureDevice requestAccessForMediaType:AVMediaTypeVideo completionHandler:^(BOOL granted) {if (granted) {// 允许} else {// 拒绝}}];

 

麦克风同相机,修改传入枚举类型

赞(0) 打赏
未经允许不得转载:爱站程序员基地 » iOS获取相机、麦克风权限