forkingdog / UITableView-FDTemplateLayoutCell

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

结合Masonry使用的时候, 会出现约束冲突, 以前版本没有, 最近突然工程多了好多冲突 #365

Open GFDreamer opened 6 years ago

GFDreamer commented 6 years ago

一下两个冲突, 使用的是相同的代码, 但是 冲突不同版本 不一样 冲突如下: 使用版本 1.6 [LayoutConstraints] 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. ( "<MASLayoutConstraint:0x60c0000b1b80 UIView:0x7fb03fe10560.top == UITableViewCellContentView:0x7fb03fe10200.top>", "<MASLayoutConstraint:0x60c0000b1c40 UIView:0x7fb03fe10560.bottom == UITableViewCellContentView:0x7fb03fe10200.bottom>", "<MASLayoutConstraint:0x60c0000b1f40 UIImageView:0x7fb03fe10e40.top == UIView:0x7fb03fe10560.top + 15>", "<MASLayoutConstraint:0x60c0000b21e0 UIImageView:0x7fb03fe10e40.height == 60>", "<MASLayoutConstraint:0x60c0000b22a0 UIImageView:0x7fb03fe10e40.bottom == UIView:0x7fb03fe10560.bottom - 15>", "<NSLayoutConstraint:0x600000283480 UITableViewCellContentView:0x7fb03fe10200.height == 44>" )

Will attempt to recover by breaking constraint <MASLayoutConstraint:0x60c0000b21e0 UIImageView:0x7fb03fe10e40.height == 60> 但其实约束 是没有问题的,

使用1.4版本 冲突如下 [LayoutConstraints] 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. ( "<NSLayoutConstraint:0x60c00009e870 UITableViewCellContentView:0x7fd2701130c0.width == 414>", "<NSLayoutConstraint:0x60800008aeb0 UITableViewCellContentView:0x7fd2701130c0.width == 0>" )

Will attempt to recover by breaking constraint <NSLayoutConstraint:0x60c00009e870 UITableViewCellContentView:0x7fd2701130c0.width == 414>

huangkaizhan commented 6 years ago

同样遇到

shanglina commented 6 years ago

同遇到,何解

HZHCoder1990 commented 6 years ago

同样遇到了 怎么解决啊?

dagundejuzi commented 6 years ago

应该不是这个框架的问题,我纯用 masonry,也出现这样的情况。仔细看了列出的约束,完全没问题,改了任何一个都会布局失败。

ohhkkk commented 6 years ago

同样的问题 但是我用系统的自动计算就没问题 用了这个就一直报约束有问题 网上加断点的那个也试过 没有约束不明确的啊

bytebai920 commented 6 years ago

我也遇到这个问题了,一个改cell 约束,发现跟框架有关系,有解决的吗,想请教一下怎么去掉约束冲突

GFDreamer commented 6 years ago

这个暂时没有找到好的解决办法, 但是不影响布局

kou8910 commented 6 years ago

设置自动行号 可以解决这个问题的 tableView.rowHeight = UITableViewAutomaticDimension tableView.estimatedRowHeight = 100 cell的view给上下左右添加约束,自己适配

harry491 commented 5 years ago

可以通过修改约束优先级来消除约束警告

与底部约束的控件可以这样写 [self.bottomView mas_makeConstraints:^(MASConstraintMaker *make) { make.top.mas_equalTo(....mas_bottom).offset(10); make.left.mas_equalTo(self.contentView).offset(15); make.size.mas_equalTo(CGSizeMake(100, 20)); make.bottom.mas_equalTo(self.contentView).offset(-15).priorityHigh(); }]; 消除contentview.height= 44; 可以设置

Jason8Zhang commented 4 years ago

楼上厉害了,这个问题也让我纠结了好久

Zhangguiguang commented 4 years ago

可以通过修改约束优先级来消除约束警告

与底部约束的控件可以这样写 [self.bottomView mas_makeConstraints:^(MASConstraintMaker *make) { make.top.mas_equalTo(....mas_bottom).offset(10); make.left.mas_equalTo(self.contentView).offset(15); make.size.mas_equalTo(CGSizeMake(100, 20)); make.bottom.mas_equalTo(self.contentView).offset(-15).priorityHigh(); }]; 消除contentview.height= 44; 可以设置

  • (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier { self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]; if (self) { self.selectionStyle = UITableViewCellSelectionStyleNone; self.contentView.bounds = CGRectMake(0, 0, 9999, 9999); } return self; }

太棒了!我要赞美你!