IOS development-custom multi-choice album
The main idea of custom multi-choice album is to import the AssetsLibrary framework to obtain the resource group from the resource library [0]. filter the [1] photo and then display the group in the list. Click the resource group to go to the corresponding album and retrieve all the photo Resources in the group. [2]
[0] obtain Resource group [_ assetsLibrary enumerateGroupsWithTypes: ALAssetsGroupAll usingBlock: ^ (ALAssetsGroup * group, BOOL * stop) {if (group) {[_ assetsArray addObject: group] [_ tableView reloadData] ;}} failureBlock: ^ (NSError * error) {UIAlertView * alert = [[UIAlertView alloc] initWithTitle: @ prompt message: @ album acquisition failed delegate: self cancelButtonTitle: @ cancel otherButtonTitles: nil]; [alert show];}];
[1] filter [_ assetsGroup setAssetsFilter: [ALAssetsFilter allPhotos];
[2] obtain the Photo Resource-(void) getImages {_ thumbnailMeasure = (SCREEN_WIDTH-(self. numberOfImageEachRow + 1) * PHOTO_DEFAULT_MARGIN)/self. numberOfImageEachRow; CGRect frame = CGRectMake (0, 0, _ thumbnailMeasure, _ thumbnailMeasure); [self. assetsGroup enumerateAssetsUsingBlock: ^ (ALAsset * result, NSUInteger index, BOOL * stop) {if (result) {AssetView * assetView = [[AssetView alloc] initWithAsset: result WithFrame: frame]; assetView. delegate = self; [_ assetsArray addObject: assetView] ;}}];}
Related Operations
Get Resource Group Name
[_ AssetsGroup valueForProperty: ALAssetsGroupPropertyName];
Retrieve the thumbnail of a Resource Group poster
[UIImage imageWithCGImage: _ assetsGroup. posterImage];
Obtain a square thumbnail of A Photo Resource
[UIImage imageWithCGImage: _ asset. thumbnail];
Obtain images with full resolution of photo resources (first encapsulate image resources)
[[Asset defaultRepresentation] fullResolutionImage];
Obtain resource types
[Asset valueForProperty: ALAssetPropertyType];