Has anyone got any idea how to debug this?
Warning once only: Detected a case where constraints ambiguously suggest a height of zero for a tableview cell's content view. We're considering the collapse unintentional and using standard height instead.
The rows have a fixed height as set by
- (CGFloat)tableView:(UITableView *)tableView
heightForRowAtIndexPath:(NSIndexPath *)indexPath{
return 34.0;
}
And all the constraints
seem to be happy...
I used Row Height 43 (or <> 44) in the Table View size inspector and the error disappeared. Using 44 I get the error. Xcode version 6.0.1.
-- This answer was removed by a moderator, please don't, it fixes the problem. This SOLVES the problem for me and may do it for others too. So could you be so kind not to delete it again.
If you're using autoLayout constraints and UITableViewAutomaticDimension, this error is not some erroneous problem to be discarded by overriding your height in code. It means that determining the cell height automatically isn't working because you don't have the proper vertical constraints needed.
If you're like me and were getting this error and needed help identifying which cell was throwing the error, you can add the following line right before the return of your 'heightforRowAtIndexPath' method.
This will print out a long list of sections and rows, but the error will appear immediately following the particular cell that is causing the error, and you can quickly identify which cell is causing the problem and fix your constraints accordingly. This is particularly helpful for static cells. Overriding the height with a manually entered number will work if you're not using autoLayout and automatic cell heights, but will essentially disable these features which is a very poor solution if its something you're trying to utilize.
If you weren't previously using the 'heightForRowAtIndexPath' method but want to debug this error without undoing your UITableViewAutomaticDimension setting, simply add this to your code:
If you're getting that warning, it's most likely because you're using auto layout and your cells don't have any constraints inside them.
You should either stop using auto layout or implement constraints that unambiguously define the height of the cells.
You can turn auto layout off in interface builder by unchecking the "Use Autolayout" option in the file inspector on the right.
If you choose to use auto layout and the height of your cells is fixed, implementing the appropriate constraints should be easy. Simply add height constraints for subviews of the cell's content view, and implement vertical space constraints between the subviews, and between the subviews and the content view. For example if your cell has one label in it, this would work:
Vertical constraints
Horizontal constraints
I couldn't get to remove the warning, but to make constraints work I set the ,new to iOS8 , tableview property
estimatedRowHeight
to the fixed height, and removedheightForRowAtIndexPath
implementation.I've also seen this error when using universal storyboards or xibs. If you neglect to specify proper constraints for the Any x Any size class, I've seen this error appear.
Apple seems to have fixed this for iOS9. The error only happened on 8.4 for me.
I was using a mapView inside uitableviewcell. I changed the height of map view to 1/3th of the device screen size. I got the same error. I fixed the error by adding missing constraints to the content view of the uitableviewcell.
1) Clear the contentView constraints.
2) Set Reset to Suggested constants to contentView.
3) Add missing constraints - if any
4) We make sure the content view has all the required constraints.