swift - UITableView and automatic height -


ok have uitableview , custom uitableviewcell. custom cell has title, below sub-title, below uiimageview (aspect fit) , below button. titles 1 line of text element varying height uiimageview. i've assigned 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 didn't give image view height or width constraint because images of varying size. sure create trail of constraints going top of cell bottom. set posttable.rowheight = uitableviewautomaticdimension automatically adjust cell height , gave fair estimate of height.

however when run application there huge amount of space @ top , bottom of image view. strange because set constraint on image 20px below sub-title label, , set constraint on button 8px below image, not happen @ all. issue here? constraints posted above constrains on entire view.

ok figured out, stumbles upon issues image aspect fit mode throws off cell height calculation. have apply constraint manually before setting uiviewimage.image.

see more info: auto-layout: uiimageview height calculate cell height correctly


Comments