Menu

#642 Card Edit: Conflict on Layout constraint for multi-line fields

iphone_1.10
closed
nobody
None
5
2020-07-11
2020-07-11
No

The following error message was seen at svn 4019, testing on simulator for iPhone SE 2nd gen.

[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:0x600002eb9e00 datafieldcell:0x7fbac8445770.top="" +="" 2="" uilabel:0x7fbacb152be0'frage'.top="=" (active)="">",
"<nslayoutconstraint:0x600002eba0d0 v:<span="">[UILabel:0x7fbacb152be0'Frage']-(2)-[UILabel:0x7fbacb153050'Halli - Hallo\nTri tra tru...'] (active)>",
"<nslayoutconstraint:0x600002eba120 (active)="" tra="" hallo\ntri="" -="" datafieldcell:0x7fbac8445770.bottom="" 2="" uilabel:0x7fbacb153050'halli="" tru...'.bottom="=">",
"<nslayoutconstraint:0x600002eba170 tru...'.height="=" tra="" 44="" hallo\ntri="" -="" (active)="" uilabel:0x7fbacb153050'halli="">",
"<nslayoutconstraint:0x600002eba440 'uiview-encapsulated-layout-height'="" datafieldcell:0x7fbac8445770.height="=" (active)="" 44="">"
)</nslayoutconstraint:0x600002eba440></nslayoutconstraint:0x600002eba170></nslayoutconstraint:0x600002eba120></nslayoutconstraint:0x600002eba0d0></nslayoutconstraint:0x600002eb9e00>

Will attempt to recover by breaking constraint
<nslayoutconstraint:0x600002eba170 tri="" hallo="" tru...'.height="=" tra="" 44="" -="" (active)="" uilabel:0x7fbacb153050'halli=""></nslayoutconstraint:0x600002eba170>

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.</uikitcore>

Discussion

  • Christa Runge

    Christa Runge - 2020-07-11

    Notes: 1) the affected card has a multi-line content.
    2) We implement a method calculateHeightsOfTextFields which uses hard-coded constants in the formula. This might be dangerous.

    Since iOS 7 the UITableView provides a method estimatedRowHeight:
    Providing a nonnegative estimate of the height of rows can improve the performance of loading the table view.
    The default value is UITableViewAutomaticDimension, which means that the table view selects an estimated height to use on your behalf. Setting the value to 0 disables estimated heights, which causes the table view to request the actual height for each cell. If your table uses self-sizing cells, the value of this property must not be 0.
    When using height estimates, the table view actively manages the contentOffset and contentSize properties inherited from its scroll view. Do not attempt to read or modify those properties directly.

     

    Last edit: Christa Runge 2020-07-11
  • Christa Runge

    Christa Runge - 2020-07-11

    1) the calculated height values are used at two places:
    a) in heightForRowAtIndexPath (for the table)
    b) as a height constraint for the DataFieldCell.
    2) When I remove the height constraint for the cell, the conflict is gone.
    3) When I additionally remove the heightForRowAtIndexPath, it does not show multi-line content.
    4) When I add the height constraint for the cell again, I get:
    a) again the conflict warning.
    b) additionally a warning (possibly for an empty cell): "Detected a case where constraints ambiguously suggest a height of zero for a table view cell's content view. We're considering the collapse unintentional and using standard height instead."
    c) and no multi-line content.

     
  • Christa Runge

    Christa Runge - 2020-07-11

    Solution: Removed the height constraint and related setter from DataFieldCell.
    Impact on CardEditViewController and DataWizardViewController.
    To be tested on both views with single-line, multi-line and empty field.

     
  • Christa Runge

    Christa Runge - 2020-07-11

    Fixed in svn4020. Tested ok.

     
  • Christa Runge

    Christa Runge - 2020-07-11
    • status: open --> closed
     

Log in to post a comment.