I'm struggling with the following problem: I have a TableViewController in which every cell has only an imageView. It uses autolayout to cell's contentView's margins and it is set to aspectFit. What I want is the height of cell to size accordingly to the imageView's height. In the first screenshot you see the white spaces at each side of the first image and at the top (and also the bottom - second screenshot) of the second image.
Note: my images' aspect ratio is variable.
I've already set this with no luck:
self.tableView.rowHeight = UITableViewAutomaticDimension
self.tableView.estimatedRowHeight = 300
Also this in cellForRowAt:
cell.setNeedsLayout()
cell.layoutIfNeeded()
Any advice is well received.
Thank you.