I have a UIImageView, with scaling Center, so it's size changes according to the UIImage inside, however, by setting a nil UIImage, the constraints break, as no content size can be calculated
How to handle the autolayout with nil UIImage (the size should be changed to 0,0)?
The problem is that UIImageView
returns {-1, -1} as intrinsicContentSize when no image is set. Use subclass of UIImageView
with implementation like this:
@implementation MyImageView
- (CGSize)intrinsicContentSize
{
if (self.image)
{
return [super intrinsicContentSize];
}
return CGSizeZero;
}
@end
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With