iOS Development code nine Gongge

Source: Internet
Author: User

Through Uiscrollview display pictures, if directly to the Uiscrollview add Uiimageview, in the number of pictures is not a problem, but when we add a lot of pictures, will occupy a lot of memory, Let's talk about how to prevent this from happening by rebuilding a uiscrollview that can implement view reuse!

The first step: Create a custom Uiscrollview

1, add two protocol to obtain the corresponding data through the proxy, determine the margin type by an enumeration type

  2. Implement the following code:

3, the implementation of the time we can through the layoutsubviews (Uiscrollview sliding time will be called) method to achieve, by sliding to determine what should be displayed, those should not be displayed, if it should be displayed, We add the Addsubview method to the Uiscrollview, and if it should not be displayed, and if it does exist, we'll get him out of the uiscrollview and put it in a cache pool.

4, when using, through a nsstring * to determine the required re-use of the view type, and then get from the cache pool

5, the final running program, such as, no matter how to slide, memory consumption will be much smaller than before

Jerry Education
Source:http://www.cnblogs.com/jerehedu/
Copyright Notice: The copyright of this article belongs to cigarettes DeskJerry EducationSection Technology Co., Ltd. and blog Park are shared, welcome reprint, but without the consent of the author must retain this paragraph, and in the article page obvious location to the original link, otherwise reserves the right to pursue legal responsibility.
Technical Consultation:

iOS Development code nine Gongge

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.