UIExpandableTableView is a UITableView subclass that gives you easy access to expandable and collapsable sections by just implementing a few more delegate and dataSource protocols. (iPhone, iPad, iOS)
Objective-C
Pull request Compare This branch is 7 commits ahead, 46 commits behind OliverLetterer:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
Screenshots
UIExpandableTableViewSample
.gitattributes
.gitignore
LICENSE.md
MTExpandableTableView.h
MTExpandableTableView.m
README.md

README.md

UIExpandableTableView

UIExpandableTableView is a UITableView subclass that gives you easy access to expandable and collapsable sections by just implementing a few more delegate and dataSource protocols.

Changes from original UIExpandableTableView

Code was added to initWithCoder: that enabled normal UIExpandableTableView use when created from Interface Builder

How to use UIExpandableTableView

  • Load the UIExpandableTableView in a UITableViewController
- (void)loadView {
    self.tableView = [[UIExpandableTableView alloc] initWithFrame:CGRectZero style:UITableViewStylePlain];
}
  • Implement the UIExpandableTableViewDatasource protocol
- (BOOL)tableView:(UIExpandableTableView *)tableView canExpandSection:(NSInteger)section {
    // return YES, if the section should be expandable
}

- (BOOL)tableView:(UIExpandableTableView *)tableView needsToDownloadDataForExpandableSection:(NSInteger)section {
    // return YES, if you need to download data to expand this section. tableView will call tableView:downloadDataForExpandableSection: for this section
}

- (UITableViewCell<UIExpandingTableViewCell> *)tableView:(UIExpandableTableView *)tableView expandingCellForSection:(NSInteger)section {
    // this cell will be displayed at IndexPath with section: section and row 0
}
  • Implement the UIExpandableTableViewDelegate protocol
- (void)tableView:(UIExpandableTableView *)tableView downloadDataForExpandableSection:(NSInteger)section {
    // download your data here
    // call [tableView expandSection:section animated:YES]; if download was successful
    // call [tableView cancelDownloadInSection:section]; if your download was NOT successful
}

Sample Screenshots