I am creating an image polling app on iOS. The feed will be instances of the entry similar to the posted image(without borders). I created a custom UITableViewCell
using PureLayout. However, the image (which is loaded asynchronously) doesn't show up.
I tried things like invalidateIntrinsicContentSize
in the image completion handler but didn't work. I am new to AutoLayout and I am following this sample code
Here is my constraints setup for the image and the 2 top labels
- (void) updateConstraints {
if (!self.didSetupConstraints) {
self.contentView.bounds = CGRectMake(0.0f, 0.0f, 99999.0f, 99999.0f);
[NSLayoutConstraint autoSetPriority:UILayoutPriorityRequired forConstraints:^{
[self.questionLabel autoSetContentCompressionResistancePriorityForAxis:ALAxisVertical];
}];
[self.questionLabel autoPinEdgeToSuperviewEdge:ALEdgeTop withInset:kLabelVerticalInsets];
[self.questionLabel autoPinEdgeToSuperviewEdge:ALEdgeLeading withInset:kLabelHorizontalInsets];
[self.questionLabel autoPinEdgeToSuperviewEdge:ALEdgeTrailing withInset:kLabelHorizontalInsets];
[self.nameLabel autoPinEdge:ALEdgeTop toEdge:ALEdgeBottom ofView:self.questionLabel withOffset:kLabelVerticalInsets];
[NSLayoutConstraint autoSetPriority:UILayoutPriorityRequired forConstraints:^{
[self.nameLabel autoSetContentCompressionResistancePriorityForAxis:ALAxisVertical];
}];
[self.nameLabel autoPinEdgeToSuperviewEdge:ALEdgeLeading withInset:kLabelHorizontalInsets];
[self.nameLabel autoPinEdgeToSuperviewEdge:ALEdgeTrailing withInset:kLabelHorizontalInsets];
[self.nameLabel autoPinEdgeToSuperviewEdge:ALEdgeBottom withInset:kLabelVerticalInsets];
[NSLayoutConstraint autoSetPriority:UILayoutPriorityRequired forConstraints:^{
[self.mainImageView autoSetContentCompressionResistancePriorityForAxis:ALAxisVertical];
}];
[self.mainImageView autoPinEdge:ALEdgeTop toEdge:ALEdgeBottom ofView:self.nameLabel withOffset:kLabelVerticalInsets];
[self.mainImageView autoPinEdgeToSuperviewEdge:ALEdgeLeft withInset:0];
[self.mainImageView autoPinEdgeToSuperviewEdge:ALEdgeRight withInset:0];
[self.mainImageView autoPinEdgeToSuperviewEdge:ALEdgeBottom withInset:0];
self.didSetupConstraints = YES;
}
[super updateConstraints];
}