Assetslibrary/assetslibrary.h album Get

Source: Internet
Author: User

Ios8.0 previously obtained the album has Uiimagepicker (but only one at a time), if you need to select multiple, you can only customize picker

The framework used here is assetslibrary.framework, resource pool,

#import <AssetsLibrary/ALAsset.h>//Picture basic information

#import <AssetsLibrary/ALAssetsFilter.h>//group Filter, remember that only one

#import <assetslibrary/alassetsgroup.h>//Get albums

#import <assetslibrary/alassetslibrary.h>//the whole class library management class bar

#import <AssetsLibrary/ALAssetRepresentation.h>//images for more information

My side of the simple package, the general process is to get the album first, and then get the photos in the album, relatively simple, directly on the code bar

-(Nsmutabledictionary *) detailgroups {if(!_detailgroups) {_detailgroups=@{}.mutablecopy; }        return_detailgroups;}-(Alassetslibrary *) Library {if(!_library) {_library=[[Alassetslibrary alloc]init]; }    return_library;}-(Nsmutablearray *) assesgroups {if(!_assesgroups) {_assesgroups=@[].mutablecopy; }        return_assesgroups;}+ (Liuasset *) Shareasset {Staticdispatch_once_t Oncetoken; Dispatch_once (&oncetoken, ^{_shareasset=[[Liuasset alloc]init];        }); return_shareasset;}- (void) Releaseobj {if(_shareasset) {_shareasset=Nil; }}///get all the groupings- (void) Getassetsgroups: (Getassetsgroupsblock) Assetsgroup {if(Self.assesGroups.count! =0) {        if(Assetsgroup) {assetsgroup (self.assesGroups.copy); return;    }; } [Self.library Enumerategroupswithtypes:alassetsgroupall usingblock:^ (Alassetsgroup *group, BOOL *stop) {                //just need photoAlassetsfilter *onlyphotos =[Alassetsfilter Allphotos]; if(group) {[Group Setassetsfilter:onlyphotos]; if([group Numberofassets] >0) {[self.assesgroups addobject:group]; }                    }Else {            //here should be in accordance with *stop to judge, seemingly debugging when found this stop is no, but there is a reference is here the group when the last one will be nil, according to this judge            if(Assetsgroup) {assetsgroup (self.assesGroups.copy); return; }}} Failureblock:^ (Nserror *error)    {            }]; }///get group All Alasset- (void) Getallassetsbygroup: (Alassetsgroup *) Group Finish: (getassetsblock) finish{nsstring*groupname =[group Valueforproperty:alassetsgrouppropertyname]; __block Nsmutablearray*allassets =[Self.detailgroups Objectforkey:groupname]; if(allassets) {//return the data.        if(finish) {finish (allassets.copy); }        return; }    //If there is no dataAllassets =@[].mutablecopy; [Group Enumerateassetsusingblock:^ (Alasset *result, Nsuinteger index, BOOL *stop) {        //I don't know why the stop here is wrong.        if(Result) {[Allassets addobject:result]; }Else {            //Save the array in the dictionary first[self.detailgroups setobject:allassets forkey:groupname]; if(finish) {finish (allassets.copy); }            return; }            }];}///Get full screen view-(UIImage *) Getfullimagewitasset: (Alasset *) Asset {return[UIImage imagewithcgimage:[[asset defaultrepresentation] fullscreenimage];}///get thumbnail images-(UIImage *) Getthumbimagewithasset: (Alasset *) Asset {return[UIImage imagewithcgimage:[asset thumbnail];}

iOS 8, Apple abandoned the class library, a new photos class, next time to clean up the class library

Assetslibrary/assetslibrary.h album Get

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.