开发者

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

开发者 https://www.devze.com 2023-01-07 11:00 出处:网络
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references,or expertise, but this question will likely solicit debate, a
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Closed 11 years ago.

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.

0

精彩评论

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