2
votes

So I have a table that when a user hits "search" I want to collapse all the cells down to a height of 45, the user can then scroll and tap a cell in the table view which will exit the search state expanding the cells back to their original heights. The expanded heights of the cells can be dynamic based on the amount of text in a UITextView. I have setup autolayout constraints and the expanded view works well, but when I attempt to collapse the cells to a height of 45 from heightForRowAtIndexPath, I get autolayout constraint errors. Does anyone know how to setup the constraints so the cell can be sized down to a height of 45 but have a dynamic heights > 45 allowing it to fit the button and UITextView contents? Also I am using beginUpdates,endUpdates to animate the height changes, so I don't want to do a full table reload if at all possible.

Example of an expanded view layout sizes to fit the content of UITextView.

UILabel 1

UILabel 2

UITextView

UIButton

Example of collapsed view.

UILabel 1

UILabel 2

1
What constraints do you have attached to your UITableView? Paste a screenshot of the constraits or list them here. As the constraints are causing the error - we will have to see them.DerWOK

1 Answers

0
votes

So I finally figured this out. On the UITextView's vertical constraint that is anchored to the bottom of the container, I had to change the relation to be less than or equal to the distance to the bottom of the container.