views:

48

answers:

1

I'm working on making a special UIScrollView to show a timeline of events, (Like a gantt chart if you're familiar with such things) and there could potentially be dozens of these events, some visible and some not at different times.

What I'm wondering is this: should I make an implementation similar to UITableView to remove the items that have scrolled out of sight, and reuse the views for other items as they come into the screen?

It seems like it could take some work, and I don't want to waste time on it if this isn't something that will affect performance on a small scale.

I'm getting the idea from the UIScrollView class reference:

"The object that manages the drawing of content displayed in a scroll view should tile the content’s subviews so that no view exceeds the size of the screen. As users scroll in the scroll view, this object should add and remove subviews as necessary."

Thanks for any help.

+1  A: 

It depends on how much memory each item in the scrollview requires. You cant really tell unless you build it or provide more information about exact amounts and what each element in the UIScrollview contains. Removing items that are not visible is not a massive job but it can have some problems. I would first try it without removing them and optimise the elements that you add to the scrollview so they use as little memory as possible and then use instruments to check your mem usage. Then go from there. Hope that helps.

Spyker
At this point they will be subclassed UIButtons without images, and plain UIViews with black backgrounds. As for amounts, it's up to the user ultimately, I wouldn't expect more than 40 in extreme cases though.
Alex Gosselin
I dont think you will have a particular problem drawing those on screen as long as the other mem mangment in your app is good. If you fancy it try and do the dequeing system its defiantly something thats great to learn and once you know it you can apply it to a lot of various problems.
Spyker
Hi Alex you should mark this question as the answer unless you wish to add more content and redfine your question. If you need more details to feel your question complete then please go ahead and ask, myself or the community will provide.
Spyker
Sorry, takes me a few days to get back around to these, I'm only programming in my spare time. Thanks for the answer.
Alex Gosselin