简体   繁体   中英

Swift constraint warning

I tried everything but can't find the solution for this warning XCode throws at me:


I have a tableView with cells.

The cells are dynamic height, because they have a view inside them: "message bubble".

Inside the message bubble, I have a label. If you click on a message bubble, the label's top-bottom margin constraint are expanding.

And there is a time label over the message bubble.

I get this warning:

Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger.
The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKit/UIView.h> may also be helpful.
2018-08-15 10:50:40.805762+0200 PipeTest[2521:879876] [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:0x1c0296670 V:[UILabel:0x102790380'Hehe']-(14)-|   (active, names: '|':UIView:0x10278ff60 )>",
    "<NSLayoutConstraint:0x1c02945f0 V:|-(14)-[UILabel:0x102790380'Hehe']   (active, names: '|':UIView:0x10278ff60 )>",
    "<NSLayoutConstraint:0x1c0299780 UIView:0x102790b20.height == 27   (active)>",
    "<NSLayoutConstraint:0x1c0296d00 UILabel:0x102773e60' 9 minutes ago'.height == 18   (active)>",
    "<NSLayoutConstraint:0x1c02926b0 UIView:0x102790b20.bottom == UITableViewCellContentView:0x102784510.bottomMargin   (active)>",
    "<NSLayoutConstraint:0x1c02963a0 V:[UIView:0x10278ff60]-(7.67)-[UIView:0x102790b20]   (active)>",
    "<NSLayoutConstraint:0x1c0298a10 V:[UILabel:0x102773e60' 9 minutes ago']-(3)-[UIView:0x10278ff60]   (active)>",
    "<NSLayoutConstraint:0x1c0297070 UILabel:0x102773e60' 9 minutes ago'.top == UITableViewCellContentView:0x102784510.topMargin   (active)>",
    "<NSLayoutConstraint:0x1c0296760 'UIView-Encapsulated-Layout-Height' UITableViewCellContentView:0x102784510.height == 94   (active)>"
)

What am I doing wrong?

You have defined several height constraints (dimensions) as well as vertical constraints. Probably, you have over constrained. As proposed, lower the priorities of tome vertical constraints.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM