This subclass of UITableView makes the Headers to expand or collapse.
Simply drag and drop the "ExpandableTableView" directory in your project. This directory has 4 files.
ExpandableTableView.h
ExpandableTableView.m
HeaderView.h
HeaderView.m
- Change your
UITableView
class toExpandableTableView
class in storyboard. - #import "ExpandableTableView.h"
- create an
IBOutlet
of ExpandableTableView - In
numberOfRowsInSection
calltotalNumberOfRows:inSection:
- call
headerWithTitle:totalRows:inSection:
inviewForHeaderInSection
- To make all Headers start with collapsed state use
allHeadersInitiallyCollapsed
- To make all Headers start with collapsed state execpt one section use
initiallyExpandedSection