UIImageView and UIImage: how can I tune for maximum performance?

First: I am implementing a fairly complex image scrolling mechanism that allows several hundred thousand to scroll (in theory) in a single scroll. This is done by preloading small chunks on scrolling, while reusing all UIImageViews. Currently, all I do is assign the newly created UIImage objects to the reusable UIImageViews.

It might be better if you could reuse these UIImage objects by passing them new image data.

Now the problem is that I am currently using the -imageNamed: method. The documentation says it caches the image.

The problems I see in this case with -imageNamed: Since the image is scrolling from the preload range, it is no longer needed. It would be bad if it was trying to cache thousands of images while the user is scrolling and scrolling and scrolling. And if I found a way to inject the new image data into the UIImage object for reuse, then what happens to the old image that has been cached?

So, one method remains that seems interesting: -initWithContentsOfFile:

It does not cache the image. And it doesn't use -autorelease, which is fine in this case.

Do you think it would be better to use -initWithContentsOfFile: in this case?

+1


a source to share


3 answers


Only a test can tell you for sure. I tend to think that image caching is UIImage

probably extremely efficient given that it is used almost everywhere in the OS. That being said, your approach can help with the number of images displayed.



+2


a source


I would say YES. You have too many images to store in the cache, so you cannot use -imageNamed :. If your images are not rendered many times, you will not get lower performance.



0


a source


I found one link regarding this that the comments of the imageNamed method http://www.alexcurylo.com/blog/2009/01/13/imagenamed-is-evil/

0


a source







All Articles