iOS Massonry约束自定义TableViewCell自适应行高的约束冲突的问题
来源:互联网 发布:mac导入的照片请解锁 编辑:程序博客网 时间:2024/05/10 17:56
2017-12-14 17:56:56.659 project[4231:2032478] Unable to simultaneously satisfy constraints. Probably at least one of the constraints in the following list is one you don't want. Try this: (1) look at each constraint and try to figure out which you don't expect; (2) find the code that added the unwanted constraint or constraints and fix it. (Note: If you're seeing NSAutoresizingMaskLayoutConstraints that you don't understand, refer to the documentation for the UIView property translatesAutoresizingMaskIntoConstraints) [ <MASLayoutConstraint:0x7fef047f19e0 UILabel:0x7fef06824c80.top == UITableViewCellContentView:0x7fef045c40a0.top + 10>, <MASLayoutConstraint:0x7fef047b95c0 UILabel:0x7fef047f5fe0.top == UILabel:0x7fef06824c80.bottom + 10>, <MASLayoutConstraint:0x7fef047fa290 UILabel:0x7fef047fbea0.top == UILabel:0x7fef047f5fe0.bottom + 5>, <MASLayoutConstraint:0x7fef047b8450 UILabel:0x7fef047f55a0.top == UILabel:0x7fef047fbea0.bottom + 5>, <MASLayoutConstraint:0x7fef047f64b0 UILabel:0x7fef047f9500.top == UILabel:0x7fef047f55a0.bottom + 5>, <MASLayoutConstraint:0x7fef047f59c0 UILabel:0x7fef047f9500.bottom == UITableViewCellContentView:0x7fef045c40a0.bottom - 10>, <NSLayoutConstraint:0x7fef06a03f70 UITableViewCellContentView:0x7fef045c40a0.height == 44>]Will attempt to recover by breaking constraint <MASLayoutConstraint:0x7fef047b95c0 UILabel:0x7fef047f5fe0.top == UILabel:0x7fef06824c80.bottom + 10>
如上图所示:提示
<NSLayoutConstraint:0x7fef06a03f70 UITableViewCellContentView:0x7fef045c40a0.height == 44>
这表明cell.contentView的约束没有处理,走的是默认的autoresizingMask约束模式,
查看自己写的约束,发现cell的contentView没有用massonry处理(用massonry处理约束的控件,子控件.translatesAutoresizingMaskIntoConstraints = NO;子控件的这个属性自动被设置为NO);
所以只需要在
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{ if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) { self.contentView.translatesAutoresizingMaskIntoConstraints = NO; }return self;}
就可以解决约束冲突的问题
前提控制器写下如下代码,会自动计算行高
- (void)viewDidLoad { [super viewDidLoad]; self.tableView.rowHeight = UITableViewAutomaticDimension; self.tableView.estimatedRowHeight = 300;}
阅读全文
0 0
- iOS Massonry约束自定义TableViewCell自适应行高的约束冲突的问题
- iOS--Masonry解决 tableViewCell 重用时约束冲突
- tableViewCell 自适应行高的坑
- iOS端如何解决自定义滑动退出手势与TableViewCell删除手势之间的冲突问题
- iOS 约束冲突
- iOS 约束冲突解决方法
- ios 约束冲突NSAutoresizingMaskLayoutConstraint
- android 自定义控件 仿照ios storyboard 约束 设置控件宽与高的比例
- ios-自动布局约束的问题
- iOS约束的设置
- MySQL的约束问题
- UIImageView的约束问题
- iOS之如何自适应TableViewCell的高度
- iOS之如何自适应TableViewCell的高度
- 基于Householder变换的约束自适应算法
- ios根据约束计算行高
- iOS 约束的思维盲点
- iOS 浅谈ScrollView的约束。
- TCP
- 数据结构实验之排序二:交换排序
- JDK8废弃永久代
- webService 的实例开发和源码
- Java基础语法篇(2)
- iOS Massonry约束自定义TableViewCell自适应行高的约束冲突的问题
- log不写底数时底数到底是多少?
- 数据结构实验之排序三:bucket sort
- 腾讯Docker云平台GaiaStack
- 机器学习(十二):多标签分类
- 《看透SpringMVC源码》笔记之HandlerAdapter
- APP跳转
- MAVEN在Eclipse中的配置
- 通过php判断银行四要素