views:

52

answers:

1

I need to display a 20 x 15 grid of images on an iPad. Each image is 50px x 50 px.

I am using [UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"name" ofType:@"png"]] to do this but am running into performance issues. The application lags heavily. There are 14 different types of images, all 50x50 in png format.

Is there a method I could use to increase the performance?

Update: I tried using the solution found at the following link; this helped some, but did not completely solve the problem. Hopefully, it helps others. http://www.alexcurylo.com/blog/2009/01/13/imagenamed-is-evil/

+2  A: 

imageNamed will cache the image so will be faster on the second use etc. If that doesn't help then you can pre-load the images if memory is not too badly affected and then just swap them out of an NSArray or NSMutableArray for example.

Ben
You can even pre-load them on a separate thread if needed.
Peter DeWeese
I load up an array of images, then when I init an object of type UIView, I set the views image to the appropriate index in the array that holds the image.
Oh Danny Boy
Pre-loading in separate thread helped tremendously.
Oh Danny Boy