I have a tableview which has dynamic sizing cells – because they contain a textview. Everything displays correctly but I am receiving some stubborn constraints errors.
I have tried modifying and removing in every way I can think but they either persist or break functionality ( ie. removing errors breaks functionality)
The errors seem to point to an issue with the bottom ‘task’ cell.
These are the constraints that I am using for the bottom cell.
Errors below :
[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:0x282221590 UITableViewCellContentView:0x106079640.bottom == UITextView:0x1058cc000.bottomMargin + 8 (active)>",
"<NSLayoutConstraint:0x282221630 V:|-(2)-[UITextView:0x1058cc000] (active, names: '|':UITableViewCellContentView:0x106079640 )>",
"<NSLayoutConstraint:0x282222170 'UIView-bottomMargin-guide-constraint' V:[UILayoutGuide:0x283818a80'UIViewLayoutMarginsGuide']-(8)-| (active, names: '|':UITextView:0x1058cc000 )>",
"<NSLayoutConstraint:0x282221e50 'UIView-Encapsulated-Layout-Height' UITableViewCellContentView:0x106079640.height == 0 (active)>"
)
Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x282222170 'UIView-bottomMargin-guide-constraint' V:[UILayoutGuide:0x283818a80'UIViewLayoutMarginsGuide']-(8)-| (active, names: '|':UITextView:0x1058cc000 )>
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.
Could this just be a bug or is there something that I am doing wrong ?
I have also tried wtfautolayout.com and the results are a little confusing also.
Any help or ideas appreciated
thanks
2
Answers
I managed to fix the errors by changing the priority on one of the constraints
A kind person from a Facebook group sent me this useful link :
http://aplus.rs/2017/one-solution-for-90pct-auto-layout/?fbclid=IwAR2bG95eNQScExFUtjL1H5dOrzjY0FTrScET--hcttzYP3hyDJVbiRipfOA
I recommend using stack views, you will save a couple of constraints and of course the design will also look a little better, and your error mentions that it is the constraint of bottom = task text view.bottommargin + 8.
Likewise, on the design screen, your constraints may appear in red and it tells you the first two that contradict or are not satisfied in your design.