导致错误的自定义UITableViewCell垂直布局约束

导致错误的自定义UITableViewCell垂直布局约束,uitableview,ios8,nslayoutconstraint,Uitableview,Ios8,Nslayoutconstraint,当我在iPhone上运行我的应用程序时,会出现以下错误。当我在模拟器中运行它时,我不会。如果我把-12-|拿走,那么单元格的高度会缩小到大约30像素。用户界面就会崩溃。 谁能帮帮我,告诉我为什么 谢谢 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) loo

当我在iPhone上运行我的应用程序时,会出现以下错误。当我在模拟器中运行它时,我不会。如果我把
-12-|
拿走,那么单元格的高度会缩小到大约30像素。用户界面就会崩溃。 谁能帮帮我,告诉我为什么

谢谢

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) 
(
"<NSLayoutConstraint:0x170285ff0 V:|-(12)-[UIImageView:0x1741ec200]   (Names: '|':UITableViewCellContentView:0x17419c7d0 )>",
"<NSLayoutConstraint:0x170286040 V:[UIImageView:0x1741ec200(200)]>",
"<NSLayoutConstraint:0x170286090 V:[UIImageView:0x1741ec200]-(12)-|   (Names: '|':UITableViewCellContentView:0x17419c7d0 )>",
"<NSLayoutConstraint:0x174881f40 'UIView-Encapsulated-Layout-Height' V:[UITableViewCellContentView:0x17419c7d0(224)]>"
)
Will attempt to recover by breaking constraint 
<NSLayoutConstraint:0x170286090 V:[UIImageView:0x1741ec200]-(12)-|   (Names: '|':UITableViewCellContentView:0x17419c7d0 )>
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.
Warning once only: Detected a case where constraints ambiguously suggest a height of zero for a tableview cell's content view. We're considering the collapse unintentional and using standard height instead.
Unable to simultaneously satisfy constraints.
---编辑---

响应
contentView.bounds
建议: 在my
UITableViewController
中,我实现了以下功能:

_tableView.rowHeight = UITableViewAutomaticDimension;
_tableView.estimatedRowHeight = 30.0f;

因此,零高度不应成为问题。

单元格的初始高度可能小于垂直约束。这将创建初始高度冲突,直到contentView的框架发生更改

您可以使用以下方法之一解决此问题:

  • 在故事板中增加单元格的高度,使其最初适合内容

  • 将单元格contentView的边界更改为更大的大小:

    self.contentView.bounds=CGRectMake(0,0,999999,99999)

您将在的答案中找到更多详细信息

更新

“无法同时满足约束”冲突发生在尝试将单元高度设置为225点的imageView约束和尝试将单元高度设置为224点的固定高度之间


imageView垂直约束使用224(12+200+12)个点。tableView分隔符使用1点。因此,要满足所有约束条件,单元高度必须为225点。

您好,根据您的问题,设备上的约束条件似乎正在被打破,而不是it模拟器。似乎您正在尝试在单元格中设置imageview高度。当您在模拟器和设备上运行时,能否添加模拟器和设备的图像以及日志屏幕。唯一的原因似乎是由于表格视图单元格的高度。您好,很抱歉反应太晚。错误仍然出现。我没有使用故事板。用户界面是基于代码的。单元格高度必须为224,因为我定义了布局约束
V:|-12-[imageView(200)]-12-|
我不明白的是,为什么一开始就有初始高度?我没有实现
-(CGFloat)tableView:(UITableView*)tableView heightForRowAtIndexPath:(nsindepath*)indepath
我只是实现了
-(void)tableView:(UITableView*)tableView didSelectRowAtIndexPath:(nsindepath*)indepath{NSLog(@“行高:%f”,“u tableView.rowHeight);}
在绘制tableView并记录其日志后查找点
-1.0000
_tableView.rowHeight = UITableViewAutomaticDimension;
_tableView.estimatedRowHeight = 30.0f;