iOS 判断应用是否有使用相机的权限
答案:2 悬赏:0 手机版
解决时间 2021-03-28 05:45
- 提问者网友:人傍凄凉立暮秋
- 2021-03-27 13:21
iOS 判断应用是否有使用相机的权限
最佳答案
- 五星知识达人网友:封刀令
- 2021-03-27 13:40
NSString *mediaType = AVMediaTypeVideo;
AVAuthorizationStatus authStatus = [AVCaptureDevice authorizationStatusForMediaType:mediaType];
if(authStatus == ALAuthorizationStatusRestricted || authStatus == ALAuthorizationStatusDenied){
NSLog(@"相机权限受限");
return;
}
-------
全部状态
typedef NS_ENUM(NSInteger, ALAuthorizationStatus) {
ALAuthorizationStatusNotDetermined = 0, // User has not yet made a choice with regards to this application
ALAuthorizationStatusRestricted, // This application is not authorized to access photo data.
// The user cannot change this application’s status, possibly due to active restrictions
// such as parental controls being in place.
ALAuthorizationStatusDenied, // User has explicitly denied this application access to photos data.
ALAuthorizationStatusAuthorized // User has authorized this application to access photos data.
} __OSX_AVAILABLE_STARTING(__MAC_NA,__IPHONE_6_0);
注意:要添加 AVFoundation 库。
AVAuthorizationStatus authStatus = [AVCaptureDevice authorizationStatusForMediaType:mediaType];
if(authStatus == ALAuthorizationStatusRestricted || authStatus == ALAuthorizationStatusDenied){
NSLog(@"相机权限受限");
return;
}
-------
全部状态
typedef NS_ENUM(NSInteger, ALAuthorizationStatus) {
ALAuthorizationStatusNotDetermined = 0, // User has not yet made a choice with regards to this application
ALAuthorizationStatusRestricted, // This application is not authorized to access photo data.
// The user cannot change this application’s status, possibly due to active restrictions
// such as parental controls being in place.
ALAuthorizationStatusDenied, // User has explicitly denied this application access to photos data.
ALAuthorizationStatusAuthorized // User has authorized this application to access photos data.
} __OSX_AVAILABLE_STARTING(__MAC_NA,__IPHONE_6_0);
注意:要添加 AVFoundation 库。
全部回答
- 1楼网友:污到你湿
- 2021-03-27 13:58
iOS7之前都可以访问相机,iOS7之后访问相机有权限设置。
打开设置
2.拉到底端找一个应用,微信举例。
3.看到相机可以开启和关闭权限。
一般新下载的应用在点开第一会有提示要不要开启相机权限,如果没有开启,想开启的时候进行以下步骤就可以了。
打开设置
找到想查看的软件
看到相机打开后面的按钮(绿色为打开)
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯