views:

418

answers:

3

I have a tableview that only holds a few (~5)cells with a large image in each cell. Is it possible to preload all the cells to improvescrolling performance? Right now, there is a slight jerk when each cell is loaded. Thanks!

+1  A: 

I don't think it's possible to tell the TableView directly to pre-create all of its cells, but assuming that the slow part is loading your images, you could certainly pre-load your images, keep them in an NSArray or something, and then putting them into the cells as they're created should be fast.

David Maymudes
How should I go about preloading my images?
Jonah
+1  A: 

Yes. You can. And it eats memory but performance will be maximized.

But only do it when you are SURE that the cells are not too big. Also don't ever forget to release them.

Mike Chen
Great! So I guess my next question would be how do I do it.
Jonah
A: 

I found out that the reason my tableview was scrolling poorly was because of how the photos were being loaded. Using imageNamed to load the images fixed all my problems.

UIImage *theImage = [UIImage imageNamed:[[appDelegate.myDelegateDict objectAtIndex:indexPath.section] objectForKey:@"MainImage"]];
Jonah
Yes but it will retain the images in memory, not release them. So if you have lots of images, you can eventually crash the app.
just_another_coder