Invalidating UIImageView's image cache
Invalidating UIImageView's image cache
- Subject: Invalidating UIImageView's image cache
- From: Carl Hoefs via Cocoa-dev <email@hidden>
- Date: Tue, 1 Sep 2020 17:40:24 -0700
Q: What is the proper way to invalidate UIImageView's image cache?
- - -
I have an iPad app that generates a series of medical analysis UIImages in the
~/Documents area of the sandbox. I then display those images in an automated
sequence on the GUI.
Each time the app runs through its processing loop, it generates a new set of
analysis images _of the same filename_ in the ~/Documents area of the sandbox,
effectively overwriting the previous set of files there.
To display (sequence through) the generated images, I feed them to UIImageView
with
imageView.image = [UIImage animatedImageWithImages::]...
or
imageView.animationImages = [NSArray <UIImage *>]...
So far, so good; they display nicely. But, once an initial set of images has
been fed to UIImageView, it will _not_ update the images displayed with a new
set (because they have the same filenames); instead UIImageView displays the
originally cached set, even though that version of the file set no longer
exists in the sandbox.
I've tried setting UIImageView.image=nil, UIImageView.animationImages=nil,
toggling UIImageView.hidden, wiping the sandbox, etc., but no joy. Of course,
restarting the app does force-flush the cache, but that's a no-go.
The only way I've found to invalidate UIImageView's caching (without killing
the app) is to play games like generating unique filenames for each run of the
processing loop of the app. Apparently UIImageView tracks _filenames_ to
determine when to flush/update its cache!
So, if there actually exists a kosher way to do this, I welcome any/all hints!
-Carl
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden