问题
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
来源:https://stackoverflow.com/questions/34889476/swift-uitableviewautomaticdimension-not-working