I'm trying to adopt the adaptive layout in a new app and have learned quite a bit. For the last portion I had to dump text into a table and have the cells adjust to stay adaptive, seemed easy enough.
I read through a few tutorials and for iOS 8 it looks like it just comes down to two things:
Shamefully my entire day has gone out the window trying to master those mere two points... I downloaded code provided from Keith Harrison on self sizing table view cells to see it work. I duplicated his cell into my larger project and it worked, however none of my own cells worked. I deconstructed everything in his project and minimized it to the point where little is left then tried making a similar cell from scratch. I've gone through and verified every constraint, every hugging/resistance setting, etc, and yet mine fail to expand the cell height.
If anyone can point out what I'm doing wrong (and it must be tiny because everything I see is the same) I have uploaded a minimized version of his example here (GitHub).
With this example I tried a cell with a single multiline label with constraints all around along with a cell as close as possible to his cell. I found that in many of my attempts everything looked identical however I would get a UIView-Encapsulated-Layout-Height
constraint issue. With my last attempt I reduced the priority of the vertical spacing to the content container to 999 from 1000.
Things I have checked or tried with no effect:
I have my solution working now after another long stab at it. Two things:
rect
tag within the storyboard source with a defined width and height. I looked everywhere for the values in IB with no luck. Taking that out fixed my problem for the GitHub test project I posted.cellForRowAtIndexPath
method to call setNeedsDisplay
and layoutIfNeeded
on the cell being requested.Following the above everything appears to be working.