TableView with dynmic cells inside a TableViewCell with dynamic height

28 Views Asked by At

I want to implement subTableView with dynamic height inside the UITableViewCell, where as the subTableView has cells with dynamic UITableViewCell. Please share your thoughts on this if anybody have implemented this scenario.

-UItableview(Parent)
  -UItableviewCell
     -UITableView(child)
        -UItableviewCell(dynamic content).

I tried this approach, it works but only after scroll and not on the first load. How i can solve this problem? https://stackoverflow.com/a/57995132

1

There are 1 best solutions below

0
Umar Muzaffer On

Approach: For storyboard, here is the approach to increase the parent tableView height according to child tableview's content size.

  1. Create a height constraint with any value for child tableView and conect an IBOutlet that sets the child tableView height.
  2. Set the height constraint's constant to tableView.contentSize.height

self.parentTableViewHeight.constant = self.childTableView.contentSize.height