One-time multiple selection of pictures and videos in iOS

Source: Internet
Author: User

Http://www.cnblogs.com/v2m_/archive/2012/12/21/2827324.html

I. Using the system's assets Library Framework
This is the library used to access images and videos in the photos program. Several of these classes are explained below
Alasset
A variety of information including a picture or video

Alassetrepresentation
Get Alasset's various information

Alassetsfilter
To retrieve Alassets from a Alassetsgroup

Alassetsgroup
A group of Alasset, a asset can belong to more than one such group, you can add a asset to a group

Alassetslibrary
The whole picture library, you can get and edit the picture library, etc.

Some people on the internet say that this method will require authorization of geo-location information, but I have not met ...

Take a look at the official use example, when enumerating the end of nil Oh, remember to deal with the judgment.

The following example shows how can get a asset to represent the first video in the Saved Photos album.alassetslib Rary *library = [[Alassetslibrary alloc] init];//enumerate just the photos and videos group by using ALASSETSGROUPSAVEDPH OTOs. [Library Enumerategroupswithtypes:alassetsgroupsavedphotos usingblock:^ (Alassetsgroup *group, BOOL *stop) {//within the group enumeration block, filter to enumerate just videos. [Group Setassetsfilter:[alassetsfilter allvideos]];//for this example, we ' re is only interested in the first item. [Group Enumerateassetsatindexes:[nsindexset indexsetwithindex:0]options:0usingblock:^ (ALAsset *alAsset, NSUInteger Index, BOOL *innerstop) {//The end of the enumeration is signaled by asset = = Nil.if (alasset) {alassetrepresentation *re Presentation = [Alasset defaultrepresentation]; Nsurl *url = [representation URL]; Avasset *avasset = [Avurlasset urlassetwithurl:url options:nil];//do something interesting with the AV asset.}];} Failureblock: ^ (nserror *errOR) {//) typically you should handle a error more gracefully than this. NSLog (@ "No groups");}]; [Library release];

Two. Another method on the network-mhimagepickermutilselector
This is done by setting the Uinavigationcontrollerdelegate method, when the Uiimagepickercontroller is displayed on the interface, Determine whether the current list of graphs (the equivalent of alassetsgroup) or the list of pictures (equivalent to a list of alasset), adjust the size of the ScrollView if it is a list of pictures, and add a scrolling view below to display the selected picture.

The disadvantage of this method is that it is relatively troublesome to make a custom action on a selected image.

I slightly modified the next ^_^ (just a little bit, make it a little bit easier to call, and not deal with duplicate pictures or anything)

As long as the Uiviewcontroller implements the Mhimagepickermutilselector protocol, then this call is good.

[Mhimagepickermutilselector showinviewcontroller:self];

Click here to download.

Reference: http://www.cocoachina.com/bbs/read.php?tid=112242

One-time multiple selection of pictures and videos in iOS

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.