Search code examples
iosios8xcode6.1sdwebimage

Images in a CustomTableCell gets resized upon click


This would be impossible to explain without a project, hence I uploaded a small DEMO on GitHub.

I don't think the constraints are wrong. The image should be fixed in its place. Initially SDWebImage retrieves the image from the cache, but once I click on the image, the image gets resized. (It gets smaller, see top image)

enter image description here

Funny enough in my demo the images show first as red squares. Once you click on them the imageView resizes and the actual image loads. This still shows the problem though.

enter image description here

It seems to me the initial cache is not resizing according to the constraints. Could that be true?


Solution

  • this fixes it:

    [cell.imageView sd_setImageWithURL:imageURL
                          placeholderImage: nil
                                 completed:^(UIImage image, NSError error, SDImageCacheType cacheType, NSURL *imageURL) {
                                     [cell setNeedsLayout];
                                 }];