Autolayout Error with UITableView
autolayout, ios, iphone, nslayoutconstraint
Solution
UPDATE: This issue is no longer relevant in iOS 8, which adds support for self-sizing cells. It is still relevant for iOS 7 however.
Original answer (iOS 7):
Greg's answer definitely worked for me - I needed to debug my tableView:estimatedHeightForRowAtIndexPath: method. I did some debugging and some quick experiments and here are some things I learned:
Don't use UITableViewAutomaticDimension in the estimated row methods. This constant is for the header and footer methods. I guess I wasn't paying enough attention when I read the documentation :) UPDATE: UITableViewAutomaticDimension can now be used for row heights in iOS 8, part of the self-sizing cells functionality.
Estimating row height of 1.0 results in an exception: "NSInternalInconsistencyException', reason: 'table view row height must not be negative...'" Estimating less than 1.0 has strange results as well.
Estimating between 2.0 and the actual works just fine without any exceptions (although 2.0 is probably a bad choice for optimization reasons - you want to be as close to actual as possible).
The constraint exception only occurs when the estimated row height is greater than the actual row height. The closer you are to the actual, the less likely the exception will occur. How far off your estimate can be before getting the exception seems to be related to several different factors: actual row height, the position of the row, etc.
Problem
I have a TableView and I specify the height for each cell using the delegate method `tableView:heightForRowAtIndexPath:`. When I rotate the view I get this error that I don't quite understand. It can't satisfy the constraint below and breaks it to continue. ``` "<_UIScrollViewAutomaticContentSizeConstraint:0x8e8d040 UITableView:0x9423400.contentHeight{id: 213} == -1568.000000>" ``` Does anyone know what is happening and why I'm breaking this constraint?