TestsTested | ✗ |
LangLanguage | Obj-CObjective C |
License | MIT |
ReleasedLast Release | Nov 2016 |
Maintained by William Wang.
A subclass of UITableView that supports the ability to collapse or expand sections in a table view.
This library is inspired by the another similar project AECollectionView. The AECollapsableTableView handles all collapse and expand logic
AECollapsableTableView defined the toggle method for a spefic section, so that the developers can trigger the toggle action conventiently. The section can be expanded by tapping the button in the header view. You can check detail in the sample project.
Additionally, here goes the features you can utilize:
- Set initial collapsable status of all sections in Interface Builder
- Collpase all sections
- Expand all sections
- Toggle a specific section
- Check whether a specific section is expanded
- Scroll to proper content offset after toggle a specific section
Subclassed the UITableView and utilize methods:beginUpdate, endUpdate, insertRowsAtIndexPaths and deleteRowsAtIndexPaths to implement the collapse and expand behavor of the table view section.
AECollapsableTableView wrapped the section collaps and expand actions. Let's take a quick look at an example,
Steps
In the storyboard, set the class of the table view in your view controller to AECollapsableTableView.
Add the tableview view outlet in your view controller by dragging the AECollapsableTableView instance as a outlet from the storyboard to your .h or .m file.
In the proper place of your own .m file(e.g. when tapping the header view of the section), invoke AECollapsableTableView's method toggleCollapsableSection:
Please check more detail information in the sample project in this repository.
[self.tableView toggleCollapsableSection:btn.tag];
Originally designed & built by William (@canicelebrate). Distributed with the MIT license.