I have a UITableViewCell with multiple pieces of data organized into a vertical stack layout. A few of them are dynamic vertically, one being a UILabel, and one being a UIImageView.
The UIImageView is what I'm having trouble with. I've setup a height constraint with an outlet in my UITableViewCell. The images load async, so the height of the UITableViewCell row will be wrong and we only know the true height of the row once the image is loaded. When I set the constraint to update to appropriate aspect ratio after image is loaded my UITableView gets completely unreliable with images jumping all over the place and formatting not working very well at all.
I have come across another article in StackOverflow that mentioned you should pre-examine the images, get their width and height so we can determine that and set constraints before the image is loaded. This does allow for smooth scrolling.
My question is: Is this the only way? Are there better techniques to using AutoLayout with dynamic image sizes? What would they be?
I've tried calling setNeedsLayout, setNeedsUpdateConstraints, updateConstraintsIfNeeded etc... None of them seem to work.
Any advice?
James