Reputation: 1
In my collection view one of my cells has a UIImageView who's UIViewContentMode is UIViewContentModeScaleAspectFit.
The UIImageView has constraints that resize it's frame on orientation change.
Most of the time everything works wonderfully. But every once in a while the UIImage is cropped when rotated. It seems to have something to do with the reuse (dequeueReusableCellWithReuseIdentifier) as it only happens after a reuse.
In my prepareForReuse I am setting the constraints as they are in my xib.
I have tried setNeedsDisplay. Anyone have any suggestions?
Upvotes: 0
Views: 77
Reputation: 11
I've run into a very similar issue. A collectionView with the cell defined in a xib. The cell has a view that contains UIImageView, which sets width constraint based on orientation mode. It turned out that - contentMode set on the UIImageView was being changed underneath. I would suggest take a look at contentMode and ensure that it is set appropriately (see reference) - either either ScaleAspectFit or ScaleAspectFill
Upvotes: 1