Skip to content

Instantly share code, notes, and snippets.

@qy1010
Created December 15, 2019 07:06
Show Gist options
  • Save qy1010/118352227fc375077a1a0d80bead7f9b to your computer and use it in GitHub Desktop.
Save qy1010/118352227fc375077a1a0d80bead7f9b to your computer and use it in GitHub Desktop.
这个方法判断是否允许使用相册的回调
[PHPhotoLibrary requestAuthorization:^(PHAuthorizationStatus status) {
if (status == PHAuthorizationStatusAuthorized) {
//允许使用相册
}else{
//不允许使用相册
}
}];
PHAuthorizationStatus photoAuthorStatus = [PHPhotoLibrary authorizationStatus];
switch (photoAuthorStatus) {
case PHAuthorizationStatusAuthorized:
NSLog(@"允许授权");
break;
case PHAuthorizationStatusDenied:
NSLog(@"不允许授权");
break;
case PHAuthorizationStatusNotDetermined:
NSLog(@"不确定");
break;
case PHAuthorizationStatusRestricted:
NSLog(@"限制");
break;
default:
break;
}
//需要在plist文件中做一些设置
相机权限: Privacy - Camera Usage Description 是否允许此App使用你的相机?
相册权限: Privacy - Photo Library Usage Description 是否允许此App访问你的媒体资料库?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment