Merge pull request #2658 from dreampiggy/bugfix_animatedimage_unused_hack_intrinsicContentSize
Remove the unused hack of intrinsicContentSize for SDAnimatedImageView
This commit is contained in:
commit
b0862c2d33
|
@ -228,8 +228,6 @@ static NSUInteger SDDeviceFreeMemory() {
|
||||||
|
|
||||||
// Ensure disabled highlighting; it's not supported (see `-setHighlighted:`).
|
// Ensure disabled highlighting; it's not supported (see `-setHighlighted:`).
|
||||||
super.highlighted = NO;
|
super.highlighted = NO;
|
||||||
// UIImageView seems to bypass some accessors when calculating its intrinsic content size, so this ensures its intrinsic content size comes from the animated image.
|
|
||||||
[self invalidateIntrinsicContentSize];
|
|
||||||
|
|
||||||
// Calculate max buffer size
|
// Calculate max buffer size
|
||||||
[self calculateMaxBufferCount];
|
[self calculateMaxBufferCount];
|
||||||
|
@ -429,23 +427,6 @@ static NSUInteger SDDeviceFreeMemory() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma mark Auto Layout
|
|
||||||
|
|
||||||
- (CGSize)intrinsicContentSize
|
|
||||||
{
|
|
||||||
// Default to let UIImageView handle the sizing of its image, and anything else it might consider.
|
|
||||||
CGSize intrinsicContentSize = [super intrinsicContentSize];
|
|
||||||
|
|
||||||
// If we have have an animated image, use its image size.
|
|
||||||
// UIImageView's intrinsic content size seems to be the size of its image. The obvious approach, simply calling `-invalidateIntrinsicContentSize` when setting an animated image, results in UIImageView steadfastly returning `{UIViewNoIntrinsicMetric, UIViewNoIntrinsicMetric}` for its intrinsicContentSize.
|
|
||||||
// (Perhaps UIImageView bypasses its `-image` getter in its implementation of `-intrinsicContentSize`, as `-image` is not called after calling `-invalidateIntrinsicContentSize`.)
|
|
||||||
if (self.animatedImage) {
|
|
||||||
intrinsicContentSize = self.image.size;
|
|
||||||
}
|
|
||||||
|
|
||||||
return intrinsicContentSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
#pragma mark - UIImageView Method Overrides
|
#pragma mark - UIImageView Method Overrides
|
||||||
#pragma mark Image Data
|
#pragma mark Image Data
|
||||||
|
|
||||||
|
|
|
@ -129,6 +129,14 @@ static const NSUInteger kTestGIFFrameCount = 5; // local TestImage.gif loop coun
|
||||||
expect(image1.animatedImageFrameCount).equal(image2.animatedImageFrameCount);
|
expect(image1.animatedImageFrameCount).equal(image2.animatedImageFrameCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void)test11AnimatedImageViewIntrinsicContentSize {
|
||||||
|
// Test that SDAnimatedImageView.intrinsicContentSize return the correct value of image size
|
||||||
|
SDAnimatedImageView *imageView = [SDAnimatedImageView new];
|
||||||
|
SDAnimatedImage *image = [SDAnimatedImage imageWithData:[self testAPNGPData]];
|
||||||
|
imageView.image = image;
|
||||||
|
expect(imageView.intrinsicContentSize).equal(image.size);
|
||||||
|
}
|
||||||
|
|
||||||
- (void)test20AnimatedImageViewRendering {
|
- (void)test20AnimatedImageViewRendering {
|
||||||
XCTestExpectation *expectation = [self expectationWithDescription:@"test SDAnimatedImageView rendering"];
|
XCTestExpectation *expectation = [self expectationWithDescription:@"test SDAnimatedImageView rendering"];
|
||||||
SDAnimatedImageView *imageView = [[SDAnimatedImageView alloc] init];
|
SDAnimatedImageView *imageView = [[SDAnimatedImageView alloc] init];
|
||||||
|
|
Loading…
Reference in New Issue