0

I have placed a custom UIView of 80x80 into a custom UITableViewCell with the following constraints.

enter image description here

The Content View of is 80 high, while the Safe Area & overall UITableViewCell is 80.5 high, presumably to account for the line between cells. Xcode does not complain during the build process. I am not setting any other hardcoded constraints elsewhere in the application.

Yet at runtime, these appears to conflict, despite seemingly not appearing incorrect:

[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)>

It seems to agree that the bounds are placed at the top and bottom, and both the cell & UIView are 80 high. What am I missing here?

marked-down
  • 9,958
  • 22
  • 87
  • 150
  • Are you sure you need the `bottom` constraint on the Wind Direction Indicator? I think if you have an explicit `height` and `width` Constraint and an X (`leading`),Y (`top`) Constraint that could be enough for AutoLayout to know where to render your view. – Aaron May 03 '19 at 21:31
  • @Aaron removing the `bottom` constraint removes these errors, but causes the cells to collapse and Xcode to issue a warning of `Detected a case where constraints ambiguously suggest a height of zero for a tableview cell's content view. We're considering the collapse unintentional and using standard height instead.` – marked-down May 03 '19 at 21:36
  • 1
    Try keeping the `bottom` constraint but lower the priority to 999. Does that fix it? – matt May 03 '19 at 21:37
  • Yes it does! But why? Is this a hack or an actual solution? – marked-down May 03 '19 at 21:38
  • Another possibility is that you are accidentally supplying a table view row height of 80. Your row height must be Automatic if you want the constraints to dictate the height. – matt May 03 '19 at 21:55
  • Hmm, maybe accidentally? I'm certainly not intentionally doing so... – marked-down May 03 '19 at 22:07

0 Answers0