views:

149

answers:

2

Hey guys,

I've started implementing a UIScrollView that will contain many thumbnail-sized pictures and will scroll only horizontally. For this, I keep a limited number of UIImageViews created and remove/add them to the UIScrollView as the user scrolls it.

The problem is I need to find a way to optimize it as scrolling sometimes gets sluggish. Maybe it's the adding/removing from the view, I don't know.

I figure this is a common component that might have been implemented more than once, but I couldn't find any library that featured something like this. If there is something ready available, I wouldn't need to spend many hours fine tuning or figuring out how to improve my component.

This is different from the question that has been asked here many times: I don't want it to behave like the photos app. I want many pictures to be visible at a time and to scroll them smoothly, without "hard pages".

So, anyone know of a component which does something similar to this?

+2  A: 

I managed to do something similar by using a rotated UITableView instead:

UITableView *tableView = [[UITableView alloc] initWithFrame:...];
tableView.transform = CGAffineTransformMakeRotation( -M_PI/2 );

You can then configure your UITableViewCells to display the images. You can also rotate the UITableViewCell contentsView.

Martin Cote
That's really clever. I wonder though, doesn't uitableview's scrolling get "sluggish" with images on it?
ahmet emrah
that's *really* cool. will try on a fresh project.
leolobato
The performances were really satisfying in my project.
Martin Cote
A: 

I made a two dimensional scrolling component called DTGridView. You can use it with just the one row to make a purely horizontal scroll view. It has an API much like UITableView, where you have a dataSource and a delegate to tell it how many rows/columns etc and to handle touch events for the cells.

It also uses a method of cell reuse like UITableView does to save on memory. If you aren't using cell reuse on table views, you should be. :)

Daniel Tull
nice, will play with the components a bit.
leolobato