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