Redeem Now
Read More
Read now

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.

. . .

Comments (3)

Add Your Comment

  • Nagaraju Kunisetty
    Can u please provide me the Project Git Hub link Please
    • bhavuk chawla
      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
    Hire Us!
    Brief us about your requirements and we'll get back to you.
    Woo! Hooy!
    We have just recieved your project brief and our expert will contact you shortly.
    Send Again