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?
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]
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.
精彩评论