I have a cell which contains 2 multi-lines labels and an UIImageView. Cell has a dynamic height and it's calculated automatically using Autolayout. My problem is that I download an image in cellForRowAtIndexPath: and until then I don't know the height of the image. At the beginning the cell doesn't has the correct layout, I have to scroll to other cells and when I go back to my cell (it re-draws) then layout is correct. How can I re-draw the cell when the image is downloaded? Here's the code I'm using:
NSString static * cellIdentifier = @"titlePostCell";
PostTitleTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
if (!cell) {
cell = [[PostTitleTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier];
}
cell.titleLabel.text = self.entry.title;
cell.descriptionLabel.text = self.entry.entry_description[@"value"];
[cell setNeedsUpdateConstraints];
[cell.postImageView pin_setImageFromURL:[[CTImageHelper sharedInstance] resizedImageURLConverterFromStringWithPrefix:self.entry.card_image] completion:^(PINRemoteImageManagerResult *result) {
cell.heightSize = [NSNumber numberWithInt:result.image.size.height/2];
cell.heightImageConstraint.constant = cell.heightSize.floatValue;
}];
return cell;
Thanks!