Is there a way to clear the cache used by UIImage class?

后端 未结 4 1463
闹比i
闹比i 2020-12-06 09:22

It is well known that UIImage caches its image data when the image is loaded using the imageNamed: method.

From apple documentation: https://developer.a

相关标签:
4条回答
  • 2020-12-06 09:23

    There is no way I know of to manually clear this iOS managed cache. In general, this is a red herring. When the os manages something for you, you don't need to worry about it. As long as you are correctly releasing anything you alloc/retain and handling memory warnings appropriately you're doing your part.

    0 讨论(0)
  • 2020-12-06 09:30

    Maybe we have more then one methods for delete cached images, but i think you can used self.cache.removeAllObjects() which is one of the more methods if you use Cache() object.If i am wrong everybody can corrected me

    0 讨论(0)
  • 2020-12-06 09:32

    The cache will be emptied when it needs to be, i.e. when the application receives a Low Memory Warning. There is no reason for you to do this yourself, and there is no public API available.

    0 讨论(0)
  • 2020-12-06 09:34

    Answer taken from Kevin Low comment


    If you can use private APIs (as in an AdHoc only app, for example) use this UIImage method to remove all images from cache

    [UIImage _flushSharedImageCache];
    
    0 讨论(0)
提交回复
热议问题