1

I've been wrestling with this for a better part of a week and I'd love some help.

I have a cell laid out in storyboards that's a subclass of UITableViewCell called EntryCell. I've been using autolayout to set constraints in storyboards and all of the constraints on all the elements are blue, lldb throws no errors at runtime so nothing is duplicated or out of place.

My label that says "Journal Entry Here" below is a UILabel and has lines set to 0.

In my view controller under ViewDidLoad, I have

    tableView.estimatedRowHeight = 185
    tableView.rowHeight = UITableViewAutomaticDimension

but when I run that, simulator shows this:

This is holding up my entire project. I've read a number of tutorials and tried their implementations to no avail. I'm currently not doing anything with heightForRowAtIndexPath. I wonder if that's the problem or if it's something else.

Any help would be hugely appreciated. Thank you!

Zack Shapiro
  • 6,648
  • 17
  • 83
  • 151

1 Answers1

2

You shouldn't have to use heightForRowAtIndexPath to get this to work. The main reason UITableViewAutomaticDimension won't expand to fit unlimited line labels is because of missing layout constraints--constraints that won't necessarily show up in the console as errors. There must be continuous anchoring for every UI Object from the top to the bottom and to the left and right of your cell for expansion to work properly. If you think you've taken care of this and the cell still doesn't expand, try posting a screen shot and list of your layout constraints so we can review.

kellanburket
  • 12,250
  • 3
  • 46
  • 73