问题
If I do
rowBackground = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"bottomCell2.png"]
the image is cached for the entire life cycle of the app or reloaded and recached everytime I execute that instruction (in other views or part of the app)?
I do that in every tableview of my app. Is it efficient?
Thanks in advance!
回答1:
As the reference of +imageNamed:
:
This method looks in the system caches for an image object with the specified name and returns that object if it exists. If a matching image object is not already in the cache, this method loads the image data from the specified file, caches it, and then returns the resulting object.
Cache is efficient, but eats memory. If your table view contains large amount of images, the memory may burn up. So you may consider +imageWithContentsOfFile:
or other similar methods to load image.
来源:https://stackoverflow.com/questions/6792000/image-caching-in-ios