0

I am trying to get auto re-sizing of my table cells working. I have simplified my cells so that I just have a single label. When running my code in the simulator on a 4s it works fine, but when running on a real 4s device I get a strange gray square over most of the table, and lots of logging with messages like:

Will attempt to recover by breaking constraint

My understanding of constraints still isnt great, but I have setup a top, bottom, leading and trailing margin on my label. I have the following in viewDidLoad:

self.tableView.estimatedRowHeight = 44.0 ;
self.tableView.rowHeight = UITableViewAutomaticDimension;

I always return UITableViewAutomaticDimension from heightForRowAtIndexPath

Is there something else I need to do to get auto sizing of table cells working on a real device?

I've tried adding calls to setNeedsUpdateConstraints and updateConstraintsIfNeeded as described in this link, but it didnt help: Using Auto Layout in UITableView for dynamic cell layouts & variable row heights

My layout, including constraints

Community
  • 1
  • 1
yarrichar
  • 423
  • 5
  • 17
  • Possible duplicate of [Using Auto Layout in UITableView for dynamic cell layouts & variable row heights](http://stackoverflow.com/questions/18746929/using-auto-layout-in-uitableview-for-dynamic-cell-layouts-variable-row-heights) –  Jan 20 '16 at 00:56
  • You don't need `heightForRowAtIndexPath` at all. You also probably have another constraint (probably related to the cell height) which is the source of the conflict. Look at the provided sample project to get an idea of which constraints you (don't) need. If you're still stuck, try searching for questions which involve the specific constraint issue. –  Jan 20 '16 at 01:06
  • I dont have any other constraints for that scene. – yarrichar Jan 20 '16 at 02:10
  • I'm also not sure if it's a constraint issue or not. The simulator shows the screen fine, but it doesn't work on the real device. – yarrichar Jan 20 '16 at 02:10

0 Answers0