这里只讲,如何使用系统的方法计算Cell高度:

要点1:XIB的布局的方式是重中之重,要遵循自上而下,比如类似朋友圈的布局;

iOS Xib约束 与 TabbleView Cell高度自适应 之 爱恨情仇

中间“detailLabel”需要自动计算高度,以detaiLabel为分割,上方控件从上而下,下方控件从下而上,detail.top =“上部控件”.bottom,detail.bottom =“下部控件”.top,不用设置DetailLabel的高度;

要点2:设置系统的预估值属性       

    tablel.rowHeight = UITableViewAutomaticDimension ;

    table.estimatedRowHeight = 300 ;


要点3:如果遇到 “unable to simultaneously satisfy constaints” 错误,

Will attempt to recover by breaking constraint

<NSLayoutConstraint:0x7fbb85e6f500 V:[UIImageView:0x7fbb85e79b80(200)]>

选中要修改的约束,将其值调低(999)即可。

iOS Xib约束 与 TabbleView Cell高度自适应 之 爱恨情仇



相关文章:

  • 2021-11-17
  • 2021-05-04
  • 2022-12-23
  • 2020-02-07
  • 2022-02-07
  • 2021-09-16
  • 2021-07-03
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-11-07
  • 2021-11-15
  • 2022-12-23
  • 2021-05-13
  • 2021-12-15
相关资源
相似解决方案