I'm using AutoLayout for iOS 8 in Xcode 6, and the last step I need on this custom Table View Cell is to add a "Bottom Space to Container Margin" constraint so my Table View Cell increases its size based on the size of the text in the Label Description
...
However, whenever I add the Bottom Space to Container Margin constraint, I get a bunch of warnings, yet if I do all the changes needed, it ends up clipping labels (all of Headline Label
, bottom of Date Label
), I'm assuming because its setting some at higher priority. And gives me this warning in the console that I'm not sure if it relates to this or something else: "Probably at least one of the constraints in the following list is one you don't want."
And I can't really run the project without cleaning up those AutoLayout warnings/errors, so was wondering if you had any ideas on what I could do or am missing?
Thanks!
UPDATE: The problem here was related to what the accepted answer had said, but I wanted to make the Q&A a bit clearer now that I have it figured out for anyone else that comes across this.
The problem was that there were fixed constraints for the height of the cell. These can either be set in storyboard or in the code (i.e. heightForRowAtIndexPath
), so make sure to check BOTH OF THESE PLACES. Once that has been removed, make sure to set UITableViewAutomaticDimension
.
What also helps is to use the Pin menu. Sometimes the labels can run off screen because it doesn't know where the constraints of the cell are based on the device size. So your label can run offscreen if the label is based off of a landscape layout but the device is an iPhone 5 and is in Portrait for example. This is the Pin menu:
Also, these things can be debugged in Storyboard Assistant Editor: Device Preview, where you are able to see the layout and layers of what is onscreen to see if maybe you have labels overlapping or going offscreen based on the device it is running on. If you want to check multiple device sized, just hit the plus icon in the lower left hand corner of this picture.
Hope I was able to clear this up so it made more sense, and provide some help while doing so!