Skip to content

Commit dffff12

Browse files
author
Olivier Poitrey
committed
If nil is given as URL to setImageWithURL:, set the image to the placeholder image (or nil if no placeholder)
This is the recommanded way clear an image for reuse (as a UITableViewCell for instance). Calling setImageWithURL: with nil URL will have the effect to cancel an eventual currently in progress download of a thumbnail for this UIImageView. Affecting the image property directly won't have this effect and may lead to image being re-affected once download is completed.
1 parent d2dc4cb commit dffff12

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

UIImageView+WebCache.m

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ - (void)setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder
2828
{
2929
cachedImage = [manager imageWithURL:url];
3030
}
31+
else
32+
{
33+
self.image = placeholder;
34+
}
3135

3236
if (cachedImage)
3337
{

0 commit comments

Comments
 (0)