iOS 不再向用户询问照片库权限。即使我从设备中删除了该应用程序。这也发生在模拟器上。
switch ([ALAssetsLibrary authorizationStatus])
{
case ALAuthorizationStatusAuthorized:
RPMLog(@"authorized");
break;
case ALAuthorizationStatusDenied:
RPMLog(@"denied");
break;
case ALAuthorizationStatusNotDetermined:
RPMLog(@"not determined");
break;
case ALAuthorizationStatusRestricted:
RPMLog(@"restricted");
break;
}
当我第一次安装应用程序时,我已经获得授权。在此之前,没有其他事件或屏幕要求照片触发用户提示。
然后我在 SavedPhotos 中请求 numberOfAssets 并在没有访问提示的情况下获取它:
ALAssetsLibrary *library = [[ALAssetsLibrary alloc] init];
[library enumerateGroupsWithTypes:ALAssetsGroupSavedPhotos usingBlock:^(ALAssetsGroup *group, BOOL *stop) {
if (!group) return;
UIActionSheet *actionSheet = nil;
if (([group numberOfAssets] > 0))
{
actionSheet = [[UIActionSheet alloc] initWithTitle:nil delegate:self cancelButtonTitle:NSLocalizedString(@"Cancel", nil) destructiveButtonTitle:nil otherButtonTitles:NSLocalizedString(@"Take new photo", nil), NSLocalizedString(@"Use last photo taken", nil), NSLocalizedString(@"Choose existing", nil), nil];
}
else
{
actionSheet = [[UIActionSheet alloc] initWithTitle:nil delegate:self cancelButtonTitle:NSLocalizedString(@"Cancel", nil) destructiveButtonTitle:nil otherButtonTitles:NSLocalizedString(@"Take new photo", nil), NSLocalizedString(@"Choose existing", nil), nil];
}
actionSheet.actionSheetStyle = UIActionSheetStyleBlackTranslucent;
[actionSheet showFromTabBar:self.tabBar];
[TestFlight passCheckpoint:@"New Look: Tab Bar"];
} failureBlock:^(NSError *error) {
NSAssert(!error, [error description]);
}];