Create expandable table view in Swift


Expandable UITableView with Animation

Expandable is very useful in an iOS application and To create it we follow the MVVM structure. First, create three classes ExpandableModal, ExpandableViewModal, ExpandableController .ExpandableController is of ViewController’s subclass, ExpandableModal, and  ExpandableViewModal.

To start creating first you know is your table view’s states is collapsible or not. and there you know the current state of your section i.e. isCollapsed or not.

After that, we need to create the custom header view that will contain title and image(will indicate us that the view state).Create a Xib of subclass  UITableViewHeaderFooterView

Then create  ExpandableModal that will contain the header data and subheader data (Your child nodes)

After that set your all data in your header

Create a reload function in your view controller which is directly bound with your view modal

Create your ExpandableViewModal and present your all data:-

So when you get all data just reload your table view categoryTableView.reloadData()


So you have successfully added an Expandable TableView in your app.

Thanks for go through this blog. Stay cool and stay updated.

. . .

Leave a Comment

Your email address will not be published. Required fields are marked*


  • Nagaraju Kunisetty
    Can u please provide me the Project Git Hub link Please
    • bhavuk chawla (Moderator)
      we didn’t upload any project to git if you need any help you can ask
  • Twinkal Ginoya
    Can you please provide CategoryMenuModel ?
  • css.php

    We've bought a Shopware Extension which is a hybrid App, which we can now offer in the Google Play Store and the IOS App Store. I'am still impressed how fast and how sharp the support team leads us through every process of the App-Store clarification. Very fast and useful response.

    Markus Walter

    Markus Walter

    Founder, Das Apartment Living

    Talk to Sales


    Live Chat
    Start a Project

      Message Sent!

      If you have more details or questions, you can reply to the received confirmation email.

      Back to Home