首页 > 解决方案 > 自动布局无法满足看似不冲突的约束

问题描述

我已将UIView80x80 的自定义放入UITableViewCell具有以下约束的自定义中。

在此处输入图像描述

Content View为 80 高,而Safe Area & 整体UITableViewCell为 80.5 高,大概是为了说明单元格之间的界限。Xcode 在构建过程中不会抱怨。我没有在应用程序的其他地方设置任何其他硬编码约束。

然而在运行时,这些似乎冲突,尽管看起来似乎不正确:

[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:0x283f60190 WindDirectionIndicator:0x104f32ac0.height == 80   (active)>",
    "<NSLayoutConstraint:0x283f60230 V:[WindDirectionIndicator:0x104f32ac0]-(0)-|   (active, names: '|':UITableViewCellContentView:0x104f326d0 )>",
    "<NSLayoutConstraint:0x283f60280 V:|-(0)-[WindDirectionIndicator:0x104f32ac0]   (active, names: '|':UITableViewCellContentView:0x104f326d0 )>",
    "<NSLayoutConstraint:0x283f60550 'UIView-Encapsulated-Layout-Height' UITableViewCellContentView:0x104f326d0.height == 80   (active)>"
)

Will attempt to recover by breaking constraint 
<NSLayoutConstraint:0x283f60190 WindDirectionIndicator:0x104f32ac0.height == 80   (active)>

似乎同意边界放置在顶部和底部,并且单元格和 UIView 都是 80 高。我在这里想念什么?

标签: iosswiftuitableviewautolayout

解决方案


推荐阅读