I'm trying without success to create a UITableViewCell
(in code, no interface builder) where the cells height expands to fit it's contents. The contents being, a UILabel
which itself expands given the text. And an UIImageView
that should also expand to to enable it till be filled with an image (maintaining aspect ratio). So a panoramic image might result in a short height, while a portrait image, will make the image much taller. The image is downloaded, so we might not know the dimensions at first.
Even if I set a constraint to fix the image view to a 4:3 aspect, resulting in a fixed image, the constraint on the cell seems to see the height as zero instead, thus the label sits on top of the image. The image overlaps the cells above and below it. Just to get it to work, in my example I'm just using a static image resource rather than downloading an image.
I'm using a VFL on the cells containerView:
V:|-[image]-[label]-|
What could be causing the image height to be treated as zero/ignored?