Introduction to Expandable and Collapsable UITableView
In this tutorial, we are going to create UITableView that will expand and collapse on tap of row or on row selection using Swift3 language for iOS app development. In more common words, showing sub-menu/ sub-items of main menu/item. Example is shown in the below given picture
Steps to create Expandable and collapsable UITableView
Step 4: To use it we will create an object of ExpandableTable and give it frame with 20 pixels gap from top.
4.1) After giving frame we will assign datasource created in last step to dataSourceForPlainTable property of ExpandedTable object.
4.2) Assign delegate to self, as we want to get notified whenever a selection is made by us.
4.3) Finally we will add it as subview to our main viewController. Below is the complete code
Step 5: Run your app and you will see the Expandable and collapsable UITableView. Tap on sub menu/ sub-item. That name will get logged on your project console.
Where to go from here
In this tutorial we learned about how to create Expandable and collapsable UITableView in iOS sdk using Swift3. You can download the full source code from here. Stay tuned for more tutorials…