'Expandable forms with UITableView?

I haave to implement 3 seperate forms, but they have headers which make the forms collapsible when clicked.

When searching online I saw the expanding rows for UITableView. Is it possible to add a custom form view in the expanded view of the tableView? Or do I try another approach with 3 hidden views that appear when each of the header sections are selected?



Solution 1:[1]

I always use UIStackView inside my cell. And when user click expand button, i unhide views and call tablewview.reloadData(). This is my approach

Solution 2:[2]

You can use 3 stack views. Each stack view will have a heading label and a tableview inside it. By default all the tableviews are hidden and heading label are not hidden. Add a tap gesture to heading labels. Whenever user taps a heading label you can unhide the respective tableview. You can give tags to each heading label and tableview so you can identify which heading label is tapped, like if a user tapped heading label with tag 1, you will unhide the tableview with tag 1.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Cavidan M?mm?dli
Solution 2 Faraz Ahmed Khan