Constraints to specify when view size is dependent on multiple subviews

前端 未结 1 1367
情书的邮戳
情书的邮戳 2021-01-16 09:56

I am using custom cell in UITableView. There are 4 views in cell. 3 UILabels and 1 UIImageView (grey colored one) as shown below. Text

相关标签:
1条回答
  • 2021-01-16 10:13

    I solved this after experimenting with lot of things. The only thing I had to do is to set horizontal and vertical content compression resistance priority to required.i.e. 1000. I did this for all labels because I don't want any of the labels to trim their content.

    One more thing which is too much important is Getting Right Height Of Cell. If there is even 1pt of error in calculating custom cell's height it will not be displayed as expected.

    Hint :

    1. If height of any view is greater than expected then possibly calculated height of cell is greater than what is actually required.
    2. If any of views is shrinking vertically or not displaying whole content then possibly calculated height of cell is lesser than what is actually required.

    Yoy can test if height is wrong by adding/removing constant value to height (variable) you calculate for cell.

    0 讨论(0)
提交回复
热议问题