Autolayouts警告,无法同时满足约束

时间:2017-08-23 18:13:03

标签: ios objective-c uitableview autolayout constraints

Tableview正在iphone5中显示,但除了iphone 5之外,我收到了这个警告。有人知道这个警告到底是什么吗?

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:0x60800008a820 UIImageView:0x7f8193515be0.height == 0.75*UITableViewCellContentView:0x7f81935153f0.height - 21   (active)>",
    "<NSLayoutConstraint:0x60800008d2a0 'UIView-Encapsulated-Layout-Height' UITableViewCellContentView:0x7f81935153f0.height == 0.5   (active)>"
)

Will attempt to recover by breaking constraint 
<NSLayoutConstraint:0x60800008d2a0 'UIView-Encapsulated-Layout-Height' UITableViewCellContentView:0x7f81935153f0.height == 0.5   (active)>

2 个答案:

答案 0 :(得分:0)

您遇到约束冲突,您可以通过向约束添加不同的优先级或删除其中一个来解决此问题。 您也可以使用恢复ID提供所有视图,因此代替&#34; UIImageView:0x7f8193515be0.height&#34;,它会出现&#39; id name&#39; .height。这样您就可以看到哪个视图遇到了约束问题。 如果你不想再次遇到这些问题,你应该学习autolayout ... AutoLayout guide

答案 1 :(得分:0)

首先,尝试将表格视图单元格中每个高度约束的优先级更改为至少999.f 显然,你有高度约束的问题。