I have a Storyboard which has a simple view hierarchy:
- View (has top/bottom constraints relative to safeArea >= 30, centerY)
- Label (has height/top(SuperView)/bottom(TextField) constraints)
- TextField (has height/top(Label)/bottom(TableView) constraints)
- TableView (has height >= 0, top(TextField)/bottom(Superview) constraints)
Inside the UITableViewDelegate (cellForRowAt):
tableView.setNeedsLayout()
tableView.layoutIfNeeded()
The behaviour I wish to achieve is to have the TableView and the parent View grow as new records are added to it. However, the parent view should not exceed its top/bottom constraints relative to the safe area.
All the elements have height constrains and spacing explicitly set, except for the table view (which has height >= 0). As well, the parent's view content hugging priority is 250 and the tableview compression resistance is 750. I thought that fixing the height constraints and spacing between elements would allow the tableview to grow up to some point because the content compression resistance is higher for the top/bottom safe area constraints than it is for the TableView.
However, XCode is forcing me to set a height or a Y position constraint for the parent view. I can't do that because then the view cannot grow automatically.
I would prefer to stick with AutoLayout and wondering if anyone has an idea or resource on how to do this.