开发者

How to display a grid of more than 1000 thumbnails as ui views in UI Scrollview with smooth scrolling

开发者 https://www.devze.com 2023-02-14 20:08 出处:网络
I have to implement a application which displays a grid view of thubmnails each of which is a clickable object. The grid view will display 2 images( which i suppose can be a uiview). And 4 rows per pa

I have to implement a application which displays a grid view of thubmnails each of which is a clickable object. The grid view will display 2 images( which i suppose can be a uiview). And 4 rows per page.

The use should be able to smoothly scroll through the image grid view. The images for the thumbnails will be fetched from the url i get from server. However assuming i have the urls in my model how can i implement this feature to display them.

Few problems i have encountered are:

  1. All the images(UIviews) cant be loaded due to memory constraints. Hence paging can be enabled.

  2. On implemented paging using uiscroll开发者_StackOverflowview delegate the ui becomes irresponsive for some time. I am downloading the images in a NSOperation queue and posting the image on mainthread for displaying on screen.

I want the scrolling to be very smooth without jerky feature. How can i implement this?

TIA, Praveen S


I was having a similar problem.
What i did was at an instance i kept only 3 pages(or screens with 4 rows as you said) in the memory and cleared remaining all.
If suppose there are 3 screens s1, s2, s3. And the user is viewing s2. Whenever he scrolls to s3 i will remove s1 and load a new page s4. So that at any point of time there will be 3 screens only.

And the users will have a better experience. And also less memory will be occupied.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号