查看系统相册权限
typedef NS_ENUM(NSInteger, ALAuthorizationStatus) {
ALAuthorizationStatusNotDetermined = 0, 用户尚未做出了选择这个应用程序的问候
ALAuthorizationStatusRestricted, 此应用程序没有被授权访问的照片数据。可能是家长控制权限。
ALAuthorizationStatusDenied, 用户已经明确否认了这一照片数据的应用程序访问.
ALAuthorizationStatusAuthorized 用户已授权应用访问照片数据.
}
需导入头文件#import <AssetsLibrary/AssetsLibrary.h>
if (author == kCLAuthorizationStatusRestricted || author ==kCLAuthorizationStatusDenied){
//无权限
NSString *tips = [NSString stringWithFormat:@"请在iPhone的”设置-隐私-照片“选项中,允许%@访问你的照片",NSLocalizedString(@"AppName",@"GMChatDemo")];
[UIAlertView showWithTitle:@" " message:tips cancelButtonTitle:@"好" otherButtonTitles:nil tapBlock:nil];
return;
}
需导入头文件#import <Photos/Photos.h>
PHAuthorizationStatus authStatus = [PHPhotoLibrary authorizationStatus];
查看系统相册权限
- 在ios7之前摄像头是一直可以访问的,隐私设置选项中没有关闭相应软件的摄像头功能的选项。在ios7以后摄像头和相册一样增加了访问权限的设置,应用中第一次访问摄像头的时候,系统会询问你是否授权应用访问你的摄像头。摄像头的权限和相册的权限基本上一样
typedef NS_ENUM(NSInteger, AVAuthorizationStatus) {
AVAuthorizationStatusNotDetermined = 0,
AVAuthorizationStatusRestricted,
AVAuthorizationStatusDenied,
AVAuthorizationStatusAuthorized
} NS_AVAILABLE_IOS(7_0);
需导入头文件#import <AVFoundation/AVFoundation.h>
AVAuthorizationStatus authStatus = [AVCaptureDevice authorizationStatusForMediaType:AVMediaTypeVideo];
查看定位权限
CLAuthorizationStatus status = [CLLocationManager authorizationStatus];
if (kCLAuthorizationStatusDenied == status || kCLAuthorizationStatusRestricted == status) {
[self showHint:NSLocalizedString(@"location.open","please open location")];
return;
}
网友评论