bmclachlin
bmclachlin

Reputation: 187

swift iOS full height table inside a table cell

Goal

I'm trying to create a table where each cell has a table inside of it. These inner tables are not scrollable and need to be full height based on their content size.

Code

Click here to see my repository with an example of what I'm trying to accomplish.

ViewController

FoodGroupCell

FoodItemCell

Problems

If I have a height constraint and no bottom constraint on the inner table the cells do not display properly.

FoodGroupCell table with a height and no bottom constraint

Simulator with a height and no bottom constraint

If I have a height constraint and a bottom constraint on the inner table the cells appear, but do not adjust their size based on the label's 200 height.

FoodGroupCell table with a height and bottom constraint

Simulator with a height and bottom constraint

This is obviously not ideal having a bottom constraint and a height at the same time. It does not seem necessary and xcode throws a bunch of warnings because of it.

Can anyone shed any light on my issue? Any help would be greatly appreciated.

Update

The problem was that I needed to update the constraint priorities, so that the height and bottom constraint could work together. I have updated my repository with the changes.

Upvotes: 0

Views: 931

Answers (1)

Steve
Steve

Reputation: 951

You may be able to work around the constraint issue by adjusting the priority of one of the two constraints so that it can adjust itself without being blocked by the constraints all having top priority.

Upvotes: 1

Related Questions