Reputation: 658
I'm making an app which has a section Instagram, which shows in a UICollectionView
all the media from a defined user. I use SDWebImage to cache the images (UIImageView+WebCache to be precise). The problem is that sometimes (I couldn't find a certain pattern) the images (the main UIImageView
that is using SDWebImage to load its content and occuppies the whole UICollectionView
and a little UIImageView
which has a defined icon that comes from the assets) resizes when scrolling and they do it in two ways:
This size changes are done with an animation, and are undesired. This problem seems to be something about the new Xcode or iOS 9, because it worked just fine in iOS 8.
Some observations:
Tell me if you need any info. Thanks!
Upvotes: 1
Views: 463
Reputation: 658
EDIT: THIS DOES NOT WORK! I kept testing, and it does work sometimes, and sometimes not.
Okay... this is the case where you were looking for an answer for a long time, and as soon as you ask, you find the answer...
Researching more I found this post: UICollectionView cell subviews do not resize
Apparently, adding the following code to the custom UICollectionViewCell
solves the issue:
- (void)awakeFromNib
{
[super awakeFromNib];
self.contentView.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth;
self.contentView.translatesAutoresizingMaskIntoConstraints = YES;
}
I hope it comes useful to someone. Cheers.
Upvotes: 1