【问题标题】:What does this console warning mean for my constraints?这个控制台警告对我的约束意味着什么?
【发布时间】:2019-07-08 05:30:32
【问题描述】:

我有一个表格视图,并在单元格内设置了约束...我遇到了一个我不明白的约束错误。这是控制台打印:

2019-07-08 01:10:56.377538-0400 TableCellDynamicHeight[5827:393085] [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. 
(
    "<_UILayoutSupportConstraint:0x2835000a0 _UILayoutGuide:0x135e164f0.height == 20   (active)>",
    "<_UILayoutSupportConstraint:0x283500000 V:|-(0)-[_UILayoutGuide:0x135e164f0]   (active, names: '|':UIView:0x135e16310 )>",
    "<NSLayoutConstraint:0x283517e80 V:[_UILayoutGuide:0x135e164f0]-(0)-[UITableView:0x13682e800]   (active)>",
    "<NSLayoutConstraint:0x2835001e0 V:|-(0)-[UITableView:0x13682e800]   (active, names: '|':UIView:0x135e16310 )>"
)

Will attempt to recover by breaking constraint 
<NSLayoutConstraint:0x283517e80 V:[_UILayoutGuide:0x135e164f0]-(0)-[UITableView:0x13682e800]   (active)>

Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger.
The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKitCore/UIView.h> may also be helpful.

这就是我的 viewController 和约束​​的样子:

【问题讨论】:

  • 尝试删除 tableview 的 top 约束并再次将其交给 safearea

标签: ios swift uitableview nslayoutconstraint


【解决方案1】:

它基本上告诉你你的约束是冲突的,它必须自动删除其中的一个。

假设您有一个高度为 40 的视图。然后你在里面放一个视图,告诉它距离顶部 10 和高度 20 和底部 0。这将导致它告诉您 1 个约束是错误的,必须删除才能工作。当您命令它的高度为 30 而实际高度为 40 时。

另一件事是,在上述情况下,如果你真的有 10 到底部。这也会造成冲突,因为视图已经知道它是 10 到底部,这意味着你基本上告诉编译器它的 10 到底部两次

【讨论】:

    猜你喜欢
    • 2021-09-30
    • 2014-08-01
    • 2016-12-06
    • 1970-01-01
    • 2021-08-26
    • 2023-01-03
    • 1970-01-01
    • 2020-08-09
    • 2018-09-04
    相关资源
    最近更新 更多