I created a xib
file for a custom cell containing a Label
and a Image View
. The Image View
width is fixed, but the height is suppose to adjust to the size of the downloaded image.
Moreover, the cell height should adjust to maintain the margin it has with the image view.
As I read several articles about auto layout, I'm not quite sure I know what I am doing so here it is: (if any of this is wrong, point out the right way)
In order to maintain the margin between the
image view
and thecell
I should create a constraint.The previous is done by selecting both
image view
andcell
, then going to Editor -> Pin -> bottom space to superview since I want to maintain the bottom margin the image view has to the cell (and the cell is the container)Until now, supposedly, if I resize the Image View height, the cell will auto-resize it's own height to maintain the margin it has before resizing.
In order to make the
Image View
height adjust to theImage
I need a constraint with .... (?)
Already read this articles and indeed they explain very well how can it be used but not specifics:
Also read this question but it doesn't says anything about auto layout at all - Change UIImageView size to match image with AutoLayout
Edit: using iOS 7