“无法同时满足约束条件的复杂布局

问题描述 投票:0回答:1

我在日志中收到以下警告:

2020-04-29 16:36:25.500796-0400 [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:0x6000033bce10 Group Color.height == 36   (active, names: Group Color:0x7f863849e0c0 )>",
    "<NSLayoutConstraint:0x6000033a96d0 V:|-(0)-[Group Color]   (active, names: Group Color:0x7f863849e0c0, Post Container:0x7f863849df50, '|':Post Container:0x7f863849df50 )>",
    "<NSLayoutConstraint:0x6000033a9b30 V:[Group Color]-(8)-[Title]   (active, names: Title:0x7f863a856990, Group Color:0x7f863849e0c0 )>",
    "<NSLayoutConstraint:0x6000033a9c20 V:[Title]-(12)-[UICollectionView:0x7f863a094200]   (active, names: Title:0x7f863a856990 )>",
    "<NSLayoutConstraint:0x6000033a9ef0 V:[UIStackView:0x7f863a859090]-(16)-|   (active, names: Post Container:0x7f863849df50, '|':Post Container:0x7f863849df50 )>",
    "<NSLayoutConstraint:0x6000033a9f40 V:[UICollectionView:0x7f863a094200]-(16)-[UIStackView:0x7f863a859090]   (active)>",
    "<NSLayoutConstraint:0x6000033aa080 UILayoutGuide:0x600002917560'UIViewSafeAreaLayoutGuide'.bottom == Post Container.bottom + 4   (active, names: Post Container:0x7f863849df50 )>",
    "<NSLayoutConstraint:0x6000033aa2b0 Post Container.top == UILayoutGuide:0x600002917560'UIViewSafeAreaLayoutGuide'.top + 16   (active, names: Post Container:0x7f863849df50 )>",
    "<NSLayoutConstraint:0x6000033bb750 'UIView-Encapsulated-Layout-Height'PostTableViewCell:0x7f86388f8a00'PostTableViewCell'.height == 100   (active)>",
    "<NSLayoutConstraint:0x6000033aa170 'UIViewSafeAreaLayoutGuide-bottom' V:[UILayoutGuide:0x600002917560'UIViewSafeAreaLayoutGuide']-(0)-|   (active, names: '|':PostTableViewCell:0x7f86388f8a00'PostTableViewCell' )>",
    "<NSLayoutConstraint:0x6000033aa0d0 'UIViewSafeAreaLayoutGuide-top' V:|-(0)-[UILayoutGuide:0x600002917560'UIViewSafeAreaLayoutGuide']   (active, names: '|':PostTableViewCell:0x7f86388f8a00'PostTableViewCell' )>"
)

Will attempt to recover by breaking constraint 
<NSLayoutConstraint:0x6000033bce10 Group Color.height == 36   (active, names: Group Color:0x7f863849e0c0 )>

我知道这是什么意思,但是在剖析它以找出应该在哪里应用修复程序时遇到了麻烦。

您可以看到,我的布局非常复杂。

ios swift xcode constraints interface-builder
1个回答
0
投票

我们必须在这里看到您的约束的图片:

navigate to main.storyboard, open the directory (bottom right), expand to find the constraints

一个常见的问题是对同一物体和侧面有两个约束

即:

label.leading = 20
label.leading = 25

如果您看到两个具有相同名称的不同约束,则将遇到“无法同时满足约束错误。”

© www.soinside.com 2019 - 2024. All rights reserved.