美文网首页
systemLayoutSizeFittingSize计算cel

systemLayoutSizeFittingSize计算cel

作者: petter102 | 来源:发表于2016-07-21 10:23 被阅读640次

这是搜索到的原文

1、在Cell对应的xib文件中建立完整的约束。

2、使用

   [cell.contentView systemLayoutSizeFittingSize:UILayoutFittingCompressedSize]
我的理解就是通过autolayout使用这个方法自动计算出cell的高度

方法对cell进行动态计算高度,然后在

  - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath

返回cell的高度。

注意:

[cell.contentView systemLayoutSizeFittingSize:UILayoutFittingCompressedSize]

一定是cell.contentView,不能用cell。

最后附上代码地址

相关文章

网友评论

      本文标题:systemLayoutSizeFittingSize计算cel

      本文链接:https://www.haomeiwen.com/subject/pkrbjttx.html