Today has been doing this thing, various degrees, online there are many examples and explanations, but it is not normal to get out. Very depressed!
Then finally all sorts of attempts, in order to let small partners less toss will, close-up this simple class.
Technical capacity is limited, there are many shortcomings, please advise!
Simple class Shortcut entry:
Link: http://pan.baidu.com/s/1hqvJLru Password: 1jd0
//Source:http://www.cnblogs.com/madordie/////Disclaimer: Write this class only to get pictures from the gallery. Because the real machine is not at hand, test only on the simulator (iOS7.1)//If you need to get other videos, you can change the fillassetgroups function yourself.//////Local photo Management//(singleton mode)//Usage://Jgphotoalbummanager *manager = [Jgphotoalbummanager shared];//[Manager setsaveallphotos:^ (Nsarray *images) {//if (!_tabledata) {//_tabledata = [[Nsmutablearray alloc] init];// }//[_tabledata removeallobjects];//[_tabledata addobjectsfromarray:images];//[_tableview Reloaddata];//}];////cell padding://Alasset *asset = _tabledata[indexpath.row];//[Cell.imageview setimage:[asset fastgetthumbnailimage];//Note://fastgetthumbnailimage for custom categories, see #import "Alasset+jgfastgetphoto.h"//
Key code:
//If you need to get other changes, the following AddObject location#pragmaMark-Fill _assetgroups-(void) fillassetgroups {alassetslibrary*assetslibrary = [Jgphotoalbummanager sharedassetslibrary];//to generate an instance of the entire photolibrary handle[Assetslibrary enumerategroupswithtypes:alassetsgroupall usingblock:^ (alassetsgroup *group, BOOL *stop) {//Get all Group if(group) {[Group Enumerateassetsusingblock:^ (Alasset *result, Nsuinteger index, BOOL *stop) {//from group insidensstring* Assettype =[result Valueforproperty:alassetpropertytype]; if([Assettype Isequaltostring:alassettypephoto]) {NSLog (@"Photo"); [_assetgroups Addobject:result]; }Else if([Assettype Isequaltostring:alassettypevideo]) {NSLog (@"Video"); }Else if([Assettype Isequaltostring:alassettypeunknown]) {NSLog (@"Unknow Assettype"); } nsdictionary*asseturls =[result Valueforproperty:alassetpropertyurls]; Nsuinteger Assetcounter=0; for(NSString *asseturlkeyinchasseturls) {NSLog (@"Asset URL%lu =%@", (unsignedLong) Assetcounter,[asseturls Objectforkey:asseturlkey]); } NSLog (@"representation Size =%lld", [[result Defaultrepresentation]size]); }]; } Else { //StopDispatch_async (Dispatch_get_main_queue (), ^ (void) {_saveallphotos (_assetgroups); }); }} Failureblock:^ (Nserror *error) {NSLog (@"enumerate the asset groups failed."); }];}Get all
@interfaceAlasset (Jgfastgetphoto)//Picture URL-(NSString *) fastgeturlstring;-(Nsurl *) Fastgeturl;//thumbnail Images-(UIImage *) Fastgetthumbnailimage;//Full Screen view-(UIImage *) Fastgetfullscreenimage;//HD Image-(UIImage *) Fastgetfullresolutionimage;//Get Time-(NSString *) fastgetdatastring;//thumbnail Images-(UIImage *) fastgetthumbnailimage {cgimagerefref=[self thumbnail]; return[UIImage imagewithcgimage:ref];}Conversion
[Original]ios7.1 method package to get all photos of the gallery