2

有没有办法在新的 iOS 6 授权方案下检查您的应用对设备照片库的授权级别?

换句话说,是否存在与照片库相反的 ABAddressBookGetAuthorizationStatus 等效项?

4

3 回答 3

6
ALAuthorizationStatus status = [ALAssetsLibrary authorizationStatus];

ALAuthorizationStatus用于显示可能值的文档。此 API 仅适用于 iOS 6.0 或更高版本。

于 2012-10-21T23:11:55.357 回答
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.
    }];
于 2012-10-21T22:41:28.117 回答
1

对于PHPhotoLibrarySwift 中的 ,您应该获得以下值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.
}
于 2019-05-24T08:56:36.670 回答