Ios 正确定义UITableViewCell大小调整的约束

Ios 正确定义UITableViewCell大小调整的约束,ios,objective-c,uitableview,Ios,Objective C,Uitableview,我目前面临这个问题,我需要定义一个动态高度UITableViewCell 红线对应于可调整大小的视图(将垂直增长),蓝色标签有3个约束:上面的每个直接红色视图两个(>=8),另一个具有170和更低优先级的superview 绿色视图对superview具有底部约束(5) 当我尝试运行代码时,它会告诉我: Unable to simultaneously satisfy constraints. Probably at least one of the constraints in the fo

我目前面临这个问题,我需要定义一个动态高度UITableViewCell

红线对应于可调整大小的视图(将垂直增长),蓝色标签有3个约束:上面的每个直接红色视图两个(>=8),另一个具有170和更低优先级的superview

绿色视图对superview具有底部约束(5)

当我尝试运行代码时,它会告诉我:

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:0x19d65bb0 V:[UIView:0x19d9a9a0(5)]>",
 "<NSLayoutConstraint:0x19d667d0 V:[UILabel:0x19de4180(19)]>",
 "<NSLayoutConstraint:0x19d5ba70 V:[UILabel:0x19d61870(19)]>",
 "<NSLayoutConstraint:0x19d36df0 V:[UILabel:0x19d36e80(19)]>",
 "<NSLayoutConstraint:0x19d35d30 V:[UIView:0x19d36130(0)]>",
 "<NSLayoutConstraint:0x19e7b310 V:|-(5)-[UILabel:0x19d6b520]   (Names: '|':UITableViewCellContentView:0x19d97580 )>",
 "<NSLayoutConstraint:0x17d0b060 V:[UILabel:0x19d6b520]-(5)-[UIView:0x19d9a9a0]>",
 "<NSLayoutConstraint:0x17d0a480 V:[UIView:0x19d9a9a0]-(8)-[UILabel:0x19de4180]>",
 "<NSLayoutConstraint:0x17d0c920 V:[UILabel:0x19de4180]-(8)-[UILabel:0x19d61870]>",
 "<NSLayoutConstraint:0x17d0a100 V:[UILabel:0x19d61870]-(8)-[UIView:0x19d839e0]>",
 "<NSLayoutConstraint:0x17d11ad0 V:[UIView:0x19d839e0]-(8)-[UILabel:0x19d36e80]>",
 "<NSLayoutConstraint:0x19e742a0 V:[UILabel:0x19d36e80]-(8)-[UILabel:0x19d36770]>",
 "<NSLayoutConstraint:0x19ed84a0 V:[UILabel:0x19d36770]-(8)-[UIView:0x19d36130]>",
 "<NSLayoutConstraint:0x19e76410 V:[UIView:0x19d36130]-(>=8)-[UILabel:0x19d35560]>",
 "<NSLayoutConstraint:0x19ed8af0 V:[UILabel:0x19d35560]-(8)-[UITextView:0x1832ba00]>",
 "<NSLayoutConstraint:0x19e7abf0 V:[UITextView:0x1832ba00]-(8)-[UILabel:0x19e7d890]>",
 "<NSLayoutConstraint:0x19e83d90 V:[UILabel:0x19e7d890]-(8)-[UITextView:0x18a95e00]>",
 "<NSLayoutConstraint:0x19e7b520 V:[UITextView:0x18a95e00]-(5)-|   (Names: '|':UITableViewCellContentView:0x19d97580 )>",
 "<NSAutoresizingMaskLayoutConstraint:0x19d46fc0 h=--& v=--& V:[UITableViewCellContentView:0x19d97580(0)]>"
)

Will attempt to recover by breaking constraint 
<NSLayoutConstraint:0x19d36df0 V:[UILabel:0x19d36e80(19)]>

Break on objc_exception_throw to catch this in the debugger.
The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKit/UIView.h> may also be helpful.
无法同时满足约束。
可能下面列表中至少有一个约束是您不想要的。试着这样做:(1)看看每个约束,试着找出你不期望的约束;(2) 找到添加了不需要的约束的代码,然后修复它。(注意:如果您看到不理解的NSAutoresizingMaskLayoutConstraints,请参阅UIView属性TranslatesAutoResizingMaskToConstraints的文档)
(
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
“=8”-[UILabel:0x19d35560]>”,
"",
"",
"",
"",
""
)
将尝试通过打破约束进行恢复
在objc_异常_抛出时中断,以便在调试器中捕获该异常。
中列出的UIView上UIConstraintBasedLayoutDebugging类别中的方法也可能会有所帮助。
因此,问题是:
实现这一点的正确方法是什么?

您是否使用
情节提要
,如果是,只需转到
编辑器->解决自动布局问题->清除……中的所有约束。。。。。。。。控制器,然后在……中添加缺少的约束。。。。。。控制器


它将帮助您解决打破视图之间矛盾的问题,但问题是如何获得[UIView sizeToFit]或[UIView.frame]以反映视图必须包含展开视图的最小大小