(a) iOS4.0 after 9.0: assetslibrary.framework
There are several classes under the framework, alassetslibrary,alassetsgroup,alasset,alassetsfilter,alassetrepresentation. (1) Alassetslibrary class: Alassetslibrary class can be implemented to view album list, add albums, save pictures to albums and other functions. For example, the Enumerategroupswithtypes method lists all albums. (2) alassetsgroup*Alassetsgroup is a class of albums, you can view the values of different properties by Valueforproperty method. such as: Alassetsgrouppropertyname, album name. *Alassetsgroup class has several methods, Posterimage method is the cover picture of the album, Numberofassets method to get the number of pictures and videos of the album, All photos can be enumerated by the Enumerateassetsusingblock method. *alassetsgroup can filter photos or videos using Setassetsfilter: (Alassetsfilter *) filters. The first is to get all the albums, using the Alassetslibrary instance method to get the Alassetsgroup class array.
Alassetslibrary *assetslibrary =[[Alassetslibrary alloc] init]; Nsmutablearray*grouparray =[Nsmutablearray array]; [Assetslibrary enumerategroupswithtypes:alassetsgroupall Usingblock:^ (Alassetsgroup *group, BOOL *stop) { if(group) {[Grouparray addobject:group]; //by this you can know the name of the album, so you can also know the installation of some applicationsNSLog (@"%@", group); }} Failureblock:^ (Nserror *error) {NSLog (@"Group not found!\n"); }];
(3) Alasset
* TheAlasset class can also view the values of different properties through the Valueforproperty method, such as: Alassetpropertytype,asset type, there are three kinds of alassettypephoto, Alassettypevideo or Alassettypeunknown. * This method can also be used to obtain alassetpropertylocation (photo location), alassetpropertyduration (video time), Alassetpropertydate (photo shoot date) and so on. The thumbnail method is to get the photo. * According to the album to get all the pictures under the album, through the Alassetsgroup instance method to get the Alasset class array.
[_group enumerateassetsusingblock:^ (Alasset *result, Nsuinteger index, BOOL *stop) { if ( Result) { [Imagearray addobject:result]; NSLog (@ "%@", result); Iv.image=*type=[result valueforproperty:alassetpropertytype]; } ];
(4) Alassetsfilter: Provide examples of filtered photos or videos. (5) The Alassetrepresentationalasset class has a Defaultrepresentation method, the return value is the Alassetrepresentation class, The purpose of this class is to obtain detailed resource information for the resource picture.
////get detailed resource information for a resource picturealassetrepresentation* representation =[Asset defaultrepresentation];//get the length and width of a resource pictureCgsize dimension =[representation dimensions];//get a high-definition image of a resource image[representation fullresolutionimage];//get a full-screen view of a resource picture[representation fullscreenimage];//get the name of the resource picturensstring* filename =[representation filename]; NSLog (@"filename:%@", filename);//Zoom Multiplier[representation scale];//Image Resource Capacity size[representation size];//Picture Resource Original Data[representation metadata];//direction of rotation[representation orientation];//The resource picture URL address, which is the same as the URL address obtained by alasset through Alassetpropertyasseturlnsurl* URL =[representation URL]; NSLog (@"url:%@", URL);//resource picture UTI, unique identifierNSLog (@"uti:%@", [representation UTI]);
Excerpt from: http://www.cnblogs.com/worldtraveler/p/4679210.html
(ii) after iOS9: photos.framework
// xxxx
iOS album (multiple picture selection)