forkingdog / UITableView-FDTemplateLayoutCell

Template auto layout cell for automatically UITableViewCell height calculating
MIT License
9.94k stars 2.01k forks source link

当一个cell里面有两个高度可变的label的时候不能正常使用 #226

Closed TonightGod closed 7 years ago

TonightGod commented 8 years ago

在使用xib创建cell的时候,cell里面有两个高度不定的label,拉完约束后,会提示设置 content compression,设置成功之后,用 `CGFloat height=[tableView fd_heightForCellWithIdentifier:kId configuration:^(TableViewCell *cell) {

    cell.model=model;
}];

当为滑动时可以全部正常显示,但是滑动之后不能正常显示,但是利用iOS 8 系统的方法 _tableview.estimatedRowHeight=40; _tableview.rowHeight=UITableViewAutomaticDimension; `这样可以正常显示

codwam commented 8 years ago

+1

codwam commented 8 years ago

这是我遇到的一种情况:

[self.view layoutIfNeeded];// iOS8 不用这句话高度会不正确 self.tableView.tableFooterView = self.footerView;

我试了看了一下,设置 dataSource 应该会直接 reloadData,这时候 tableview 还没有 update layout,所以里面的contentWidth = 0,计算出来的高度会是 -0.5(没有separator会是 0)。

Kingson commented 7 years ago

我也遇到类似问题,我的Cell里面有三个可变的Label,运行后,两个Cell叠在一起了

iamsleks commented 7 years ago

我的Cell里穿插两个UITextView ,包裹优先级设置正确,宽高依存链闭合,显示是正常的。之前有一个不按内容展开尺寸,按IB提示改了包裹优先级就可以了。关于包裹优先级苹果官方文档有说明。

afantree commented 7 years ago

@iamsleks 恩, 应该就是优先级没有设置对的问题