iOS get photos with alassets

Source: Internet
Author: User

In iOS9 to get local picture resources through the photos framework, it is Apple's current method, and the previous alassetslibrary framework is obsolete, but since IOS9 is now released shortly iOS8 and iOS7 have a certain amount of proportion, so this outdated framework, We also need to figure out how to consolidate the alassetslibrary framework.

1. What is the Alassetslibrary framework

In short, Alassetslibrary is a bridge through which our iOS app accesses native videos and photos, which allows us to easily get basic details about videos and photos.

2. Basic Use Method

    In the use of alassetslibrary, we first need to import the Alassetslibrary framework, and the way to import alassetslibrary framework is usually the first linked and then #import<> However, we can also import directly using @import, without the need for linked.

1> Get album album by Alassetslibrary: Alassetsgroup

2>. Get more information about pictures in albums by Alassetsgroup: Alassets

3. Problem solving

    After obtaining the picture resource through Alassetslibrary, it is displayed in chronological order in another TableView, where a picture is encountered that shows an incorrect problem:

1> When you first display the pull-up and pull-down will be added ImageView, then I think it is in the refactoring set method every time the helper set method will be added, so I got a global bool type, let it only add once.

2> When you add only one time, you find that the image resource data is only the initial display of the 5, so I am thinking about the model is wrong, a simple test code, the model is right.

3>. When the model is correct, the picture is still not improved effectively, so I write a simple test code to check the correctness of the model again every time I call the Set method.

4>: When the initial place of the set method, that is, the return of the UITableViewCell in the pull-up and pull-down, confirms the correctness of the model, I go to the set method to find the correctness of the model, and found that it is wrong.

Since I used the method of creating only one uitableviewcell from the beginning to the end UITableView, and repeated the application in the pull down, so that the data in each of the only 5, because it was created only once, so when I get the data is the repetition of 5, As to why it was created only once was due to my first solution.

iOS get photos with alassets

Related Article

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.