IOS development-custom multi-choice album

Source: Internet
Author: User

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];

 
 

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.