Tutorial :iphone dev - UIScrollView massive content tricks/tips [closed]



Question:

I have a horizontally scrolling UIScrollView and I want to display potentially thousands of UIImage's side by side. Obviously I can't do that for memory reasons so what I am thinking is set the content size to be the 2000 or whatever but only show the current window of image squares. So the user would flick the scroll bar and when it stops (it is paged so it will stop scrolling quickly), it will display the images that should be there at that point.

I haven't done that yet but sounds simple enough. I will just have 1 row of UIImage's moving around and loading different content depending upon which scrolling 'page' comes to rest.

First question - is that a good approach? Second question - how can I have an infinitely repeating tiled background image of empty squares or something to act as placeholders for content that hasn't been loaded. These will be displayed as the user is whirling the scroll bars around. Can we have a tiled BG image on UI elements?


Solution:1

Yes, this pretty much is the solution for this problem. Like Fossli said, you can have a massive content size and it won't make a difference, allocate the visible images and those near it, remove when they aren't needed. For a tiled bg image you could try setting the background color and creating a UIColor with [UIColor colorWithImage:myBgImage]


Solution:2

paginating and a lot of content: only allocate and initalise those images that are close to the current you view. do some listening and calculate which page you are on and then fire those up. the content size can be as big as you want, doesen't matter if you do it like this.


Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »