[Original]ios7.1 method package to get all photos of the gallery

Source: Internet
Author: User

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

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.