我创建了一个有一个UIView的单元格。
在-cellForRowAtIndexPath
我正在调用一个-updateData
选择器,其中包含一些标签。一旦添加了所有标签,我就会增加tableViewCell
的高度限制(我已经制定了高度约束的出口)
以下是我的-updateData
选择器的最后两行:
self.cellHeightConstraint.constant = yPosition + Padding;
[self layoutIfNeeded];
修改
以下是Autolayout的表格视图配置:
self.tableView.estimatedRowHeight = 90;
self.tableView.rowHeight = UITableViewAutomaticDimension;
CellForRowAtIndexPath方法
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
CustomCell *cell = [tableView dequeueReusableCellWithIdentifier:CustomCell];
[cell updateDataWithBillDetail:wrapper];
cell.selectionStyle = UITableViewCellSelectionStyleNone;
return cell;
}
当我运行此代码时,我收到以下警告:
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:0x13d8f9cf0 V:[UIView:0x13d8fb090(114)]>",
"<NSLayoutConstraint:0x13d8fb200 UIView:0x13d8fb090.top == UITableViewCellContentView:0x13d8faf10.topMargin - 8>",
"<NSLayoutConstraint:0x13d8fb250 V:[UIView:0x13d8fb090]-(0)-| (Names: '|':UITableViewCellContentView:0x13d8faf10 )>",
"<NSLayoutConstraint:0x13db6cd80 'UIView-Encapsulated-Layout-Height' V:[UITableViewCellContentView:0x13d8faf10(35.5)]>"
)
Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x13d8f9cf0 V:[UIView:0x13d8fb090(114)]>
Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger.
The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKit/UIView.h> may also be helpful.
有人可以帮助我如何删除此控制台警告?
答案 0 :(得分:0)
我认为问题出在yPosition上。将其替换为初始单元格的高度。
答案 1 :(得分:0)
我不确定,但你甚至可以为一个细胞做这个,它可能。与@ystack悲伤的高度冲突。 您是否尝试使用动态单元格大小?
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat