-1

I'm a beginner programmist

I am trying to do a note application with resizing rows, but every time I run the app it fails with this error:

Will attempt to recover by breaking constraint NSLayoutConstraint:0x60000009dce0 UILabel:0x7f956f410b90.height >= 21 (active)

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.

Full project - https://github.com/MarBaka/MemoOrganizer.git

Please help

rmaddy
  • 314,917
  • 42
  • 532
  • 579

1 Answers1

0

By default the UITableView doesn't expect rows to auto-resize. For that reason, it will break any constraints that try to make the rows bigger than expected.

The solution is to let the UITableView know that you will have dynamic heights, and you can do it so: tableView.rowHeight = UITableViewAutomaticDimension

With this you can skip the implementation of tableView:heightForRowAt: and let the UITableView calculate it by itself.

If you have a lot of rows, you might notice that the UITableView's loading gets slower. You can improve that by giving an estimation of the height of the rows by implementing tableView:estimatedHeightForRowAt.
What this does is it moves the calculation of the UITableView's content height (total height of all your rows) from load time to scroll time.

Thomas
  • 2,003
  • 18
  • 30