ios - 这个控制台警告对我的约束意味着什么?

标签 ios swift uitableview nslayoutconstraint

我有一个 TableView ,并在单元格内设置约束...我收到一个我不理解的约束错误。这是控制台打印:

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 和约束​​的样子:

enter image description here

最佳答案

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

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

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

关于ios - 这个控制台警告对我的约束意味着什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56928887/

相关文章:

ios - XCTest.框架/XCTest : no matching architecture in universal wrapper when run the app

ios - 如果字符串包含某些字符,Swift 会删除扩展字符吗?

ios - UIGesturerecognizer 不适用于 UIView

ios - 具有屏幕边缘滑动手势的水平 uitableview

html - 媒体查询不适用于 iOS

面向开发人员的 iOS 发布日期

ios - 如何在 Swift 中遵守 Strideable 协议(protocol)?

ios - 在 iOS 中,如何从子 ViewController 获取图像?

ios - 为 UITableView 标题文本设置accessibilityLabel

ios - 在 iOS9 上崩溃 -[NSPersistentStoreCoordinator _coordinator_you_never_successfully_opened_the_database_device_locked :]