我使用的是masonry纯代码布局CELL,并使用tableView的估算高度
- xcode7下运行iOS9模拟器效果:

- xcode8下运行iOS10模拟器效果:

- 发现问题所在:
我发现如果是纯代码做cell的自适应约束的话,比方说cell的
contenView底部 = 子控件底部,iOS10以下添加约束,父控
件底部 = 子控件底部 or 子控件底部 = 父控件底部都可以,
但是在iOS10下,我这边“必须”设置成子控件底部 = 父控件
底部,不然估算高度就出不来;并且奇葩的时,连左右约束
全都能给错乱掉!(并且在xib中没有什么区别,怎么做这个
约束都正常!!!)
- 例: cell高度由底部控件lineView决定,需要添加底部约束和cell的contenView底部约束为0
- 任何环境下均正常
[lineView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.right.mas_equalTo(0);
make.top.mas_equalTo(replyView.mas_bottom).mas_offset(commentMidMargin);
make.height.mas_equalTo(1);
make.bottom.mas_equalTo(self.contentView.mas_bottom);
}];
- iOS 10下运行布局异常,错乱掉!iOS 10以下正常
[lineView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.right.mas_equalTo(0);
make.top.mas_equalTo(replyView.mas_bottom).mas_offset(commentMidMargin);
make.height.mas_equalTo(1);
//make.bottom.mas_equalTo(self.contentView.mas_bottom);
}];
[self.contentView mas_makeConstraints:^(MASConstraintMaker *make) {
make.bottom.mas_equalTo(lineView.mas_bottom);
}];
- 特意去一些布局相关的开源框架查看他们的issues,发现还是蛮多人问相关问题得
-
UITableView-FDTemplateLayoutCell
-
我在这里也有回复,不知道是不是跟我的情况一样
(https://github.com/forkingdog/UITableView-FDTemplateLayoutCell)**
3.png
-
Masonry

- 帮助到大家,打赏_

网友评论