I want to achieve a desire behaviour using autolayout (or if this is not possible using a delegate or something). What I have is a tableView with one static cell, this cell has a containerView that have a tableViewController with dynamic prototype cells.
What I want is be able to use autolayout to dynamically set the height of the static cell that has the container view embedded.
This is the storyboard:
These are my constraints (static cell with the contentView of the container View):
In the viewController that have the containerView within the static cell what I have is on the ViewDidLoad method:
override func viewDidLoad() {
super.viewDidLoad()
courseDetailTableView.estimatedRowHeight = 200
courseDetailTableView.rowHeight = UITableViewAutomaticDimension
}
And using the delegate of the tableView with the staticCell:
override func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
return UITableViewAutomaticDimension
}
But with this the height of the static cell is really small... it means that the autolayout is not capable of setting the height of his content with only the constraints that I have set.. I said only the constraints because if I set one more constraint on the contentView of the containerView that set the height to something like 400 then the height of that cell is 400..
I was just wondering if there is a way with autolayout to set the height of the static cell to match the height of the containerView.
I know that maybe using a delegate that calculates first the height of the containerView and use this height to set the heightForRow at it could possible work I want to know if there is a simpler way
Thank you so much.