views:

220

answers:

3

Pretty new to iPhone / objective-C.

I have an application that has 15-100 small images (16x16 or 8x8 PNG) on the screen. For this example sake, let's assume that I can create these images using CGContext if I needed to.

I would have to assume that iPhone would perform better using that method rather than loading images (PNG's). However, the bitmap version is easier to develop and also has other advantages (like built in touch events) that I need.

If performance is not the ultimate metric for this application, does placing 100 small images degrade performance/memory enough to even consider switching to the CGContext method. My instinct tells me that I will not see that much of a performance difference either way but I am too new to iPhone development to know enough about it to make a difference.

A: 

I'd try the bitmap version first, then CGContext one if bitmap is too slow.

THEN if it's still too slow, I'd put all the icons into a GL texture.

Rhythmic Fistman
+1  A: 

I suppose it depends on the complexity of your image generation algorithm.

I will also depend on you application: will you be drawing this images many times per second, like in an animation? If that's the case, use UIImageViews.

Marco Mustapic
thanks! There will be no animation. I may refresh the entire screen every couple of seconds of so but that would be max amount of redrawing
Cody C
If the redraw is an immediate response to user interaction, you may feel a delay, so try it and see how it goes.
Marco Mustapic
+1  A: 

Hey Cody,

I think using 100 or so UIImageViews should be fine as long as you don't need to rapidly animate them or update them at the same time. You should avoid doing anything that would change the size of the views (like resizing the view that contains them all), and if you use Core Animation to animate them, perform all of the animations inside a single animation block. (Wrap everything with one [UIView beginAnimations:context:], [UIView commitAnimations] - not one for each view)

Good luck!

Ben Gotow