OK so I have a UITableView
and a custom UITableViewCell
. This custom cell has a title, below that a sub-title, below that a UIImageView
(aspect fit) and below that a button. Now the titles will always be one line of text so the only element with varying height is the UIImageView
. Now I've assigned the following constraints:
title label - top space 8px, left space 8px, right space 8px
sub-title label - top space 10px, left space 8px, right space 8px
image - top space 20px, left space 8px, right space 8px
button - top space 8px, left space 8px, bottom space 40px
Now I didn't give the image view a height or width constraint because the images will be of varying size. I was also sure to create a trail of constraints going from the top of the cell to the bottom. I also set postTable.rowHeight = UITableViewAutomaticDimension
to automatically adjust the cell height and gave a fair estimate of the height.
However when I run the application there is a HUGE amount of space at the top and bottom of the image view. Which is strange because I set a constraint on the image to be 20px below the sub-title label, and I set a constraint on the button to be 8px below the image, which does not happen AT ALL. What could be the issue here? The constraints I posted above are the only constrains on the entire view.