不同框架下相册及相机的使用权限

目前访问相册有两种框架,一个是AssetLibrary框架,在iOS6.0--iOS9.0系统可用;另一种是Photos框架,在iOS8.0以上的系统可用,可见了解这两种框架的必要性。

Photos框架

相册的使用权限

- (BOOL)judgeIsHavePhotoAblumAuthority
{
    PHAuthorizationStatus status = [PHPhotoLibrary authorizationStatus];
    if (status == PHAuthorizationStatusRestricted ||
        status == PHAuthorizationStatusDenied) {
        return NO;
    }
    return YES;
}

相机的使用权限

- (BOOL)judgeIsHaveCameraAuthority
{
    AVAuthorizationStatus status = [AVCaptureDevice authorizationStatusForMediaType:AVMediaTypeVideo];
    if (status == AVAuthorizationStatusRestricted ||
        status == AVAuthorizationStatusDenied) {
        return NO;
    }
    return YES;
}

AssetsLibrary框架

相册的使用权限

- (BOOL)judgeIsHavePhotoAblumAuthority
{
    ALAuthorizationStatus state = [ALAssetsLibrary authorizationStatus];
    if (state == ALAuthorizationStatusRestricted || state == ALAuthorizationStatusDenied) {
        return NO;
    }
    return YES;
}

相机的使用权限

- (BOOL)judgeIsHaveCameraAuthority
{
    AVAuthorizationStatus status = [AVCaptureDevice authorizationStatusForMediaType:AVMediaTypeVideo];
    if (status == AVAuthorizationStatusRestricted || status == AVAuthorizationStatusDenied) {
        return NO;
    }
    return YES;
}


你可能感兴趣的:(相册,相机,使用权限)