From 7817e8e096008fd1501b35b7e90b376cd419567e Mon Sep 17 00:00:00 2001 From: Julius Parishy Date: Fri, 27 Mar 2015 06:31:22 -0700 Subject: [PATCH] Cancel contents animation before setting new contents in RCTNetworkImageView Summary: This is a fix for #322 When setting a new image via the imageURL property, the new image doesn't always replace the previous one when it is finished downloading because the image view has a previously instated layer animation on its contents. This cancels any animation prior to setting the new contents to fix the issue. Closes https://github.com/facebook/react-native/pull/337 Github Author: Julius Parishy Test Plan: Imported from GitHub, without a `Test Plan:` line. --- Libraries/Image/RCTNetworkImageView.m | 1 + 1 file changed, 1 insertion(+) diff --git a/Libraries/Image/RCTNetworkImageView.m b/Libraries/Image/RCTNetworkImageView.m index 5ea0b64d51d3b0..c97b97cfdec7d9 100644 --- a/Libraries/Image/RCTNetworkImageView.m +++ b/Libraries/Image/RCTNetworkImageView.m @@ -75,6 +75,7 @@ - (void)setImageURL:(NSURL *)imageURL resetToDefaultImageWhileLoading:(BOOL)rese } else { _downloadToken = [_imageDownloader downloadImageForURL:imageURL size:self.bounds.size scale:RCTScreenScale() block:^(UIImage *image, NSError *error) { if (image) { + [self.layer removeAnimationForKey:@"contents"]; self.layer.contentsScale = image.scale; self.layer.contents = (__bridge id)image.CGImage; }