I'm not sure if there is any build method for this, but an easy way is to use ALAssetsLibrary to pull a meaningless bit of information from the photo library when you turn on this feature. Then you can simply cancel all the information you pulled out and you ask the user to access their photos.
The following code, for example, no more than allows you to get the number of photos in the camera frame, but will be enough to trigger a permission request.
#import <AssetsLibrary/AssetsLibrary.h> ALAssetsLibrary *lib = [[ALAssetsLibrary alloc] init]; [lib enumerateGroupsWithTypes:ALAssetsGroupSavedPhotos usingBlock:^(ALAssetsGroup *group, BOOL *stop) { NSLog(@"%zd", [group numberOfAssets]); } failureBlock:^(NSError *error) { if (error.code == ALAssetsLibraryAccessUserDeniedError) { NSLog(@"user denied access, code: %zd", error.code); } else { NSLog(@"Other error code: %zd", error.code); } }];
EDIT: Just stumbled upon this, the following shows how you can check the authorization status of your apps to access photo albums.
ALAuthorizationStatus status = [ALAssetsLibrary authorizationStatus]; if (status != ALAuthorizationStatusAuthorized) { UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Attention" message:@"Please give this app permission to access your photo library in your settings app!" delegate:nil cancelButtonTitle:@"Close" otherButtonTitles:nil, nil]; [alert show]; }
Mick MacCallum Nov 26 '12 at 20:24 2012-11-26 20:24
source share