有没有办法根据新的iOS 6授权方案检查应用程序的授权级别到设备的照片库?
换句话说,ABAddressBookGetAuthorizationStatus是否存在与照片库相反的等价物?
答案 0 :(得分:6)
ALAuthorizationStatus status = [ALAssetsLibrary authorizationStatus];
ALAuthorizationStatus
的文档显示了可能的值。此API仅适用于iOS 6.0或更高版本。
答案 1 :(得分:1)
我正在使用这个结构:
[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.
}];
答案 2 :(得分:1)
对于Swift中的PHPhotoLibrary
,您应该获得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.
}