有没有办法在新的 iOS 6 授权方案下检查您的应用对设备照片库的授权级别?
换句话说,是否存在与照片库相反的 ABAddressBookGetAuthorizationStatus 等效项?
有没有办法在新的 iOS 6 授权方案下检查您的应用对设备照片库的授权级别?
换句话说,是否存在与照片库相反的 ABAddressBookGetAuthorizationStatus 等效项?
ALAuthorizationStatus status = [ALAssetsLibrary authorizationStatus];
ALAuthorizationStatus
用于显示可能值的文档。此 API 仅适用于 iOS 6.0 或更高版本。
我正在使用这个结构:
[assetsLibrary enumerateGroupsWithTypes:ALAssetsGroupAll usingBlock:^(ALAssetsGroup *group, BOOL *stop) {
if (*stop) {
return ;
}
// TODO : access granted
*stop = TRUE;
} failureBlock:^(NSError *error) {
// TODO: User denied access. Tell them we can't do anything.
}];
对于PHPhotoLibrary
Swift 中的 ,您应该获得以下值PHAuthorizationStatus
:
let authorizationStatus = PHPhotoLibrary.authorizationStatus()
返回值为:
public enum PHAuthorizationStatus : Int {
case notDetermined // User has not yet made a choice with regards to this application
case restricted // 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.
case denied // User has explicitly denied this application access to photos data.
case authorized // User has authorized this application to access photos data.
}