Skip to content
FZAccordionTableView transforms your regular UITableView into an accordion table view.
Branch: master
Clone or download
kgaidis Merge pull request #47 from fuzz-productions/shift-fix
Updated examples and fixed UI test target causing a failure
Latest commit c3c4405 Mar 5, 2018
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
Example fixed warnings in swift static-sizing example. Mar 4, 2018
FZAccordionTableView Modified code so toggleSection: call does not require a headerView to… Sep 5, 2016
Images
Tests Cleaned up FZAccordionTableViewTests project. Fixed UI test target fa… Mar 4, 2018
.gitignore Initial commit. Jul 26, 2015
FZAccordionTableView.podspec updated podspec and README. Sep 5, 2016
LICENSE Initial commit. Jul 26, 2015
README.md

README.md

Slack Status

Overview

FZAccordionTableView transforms your regular UITableView into an accordion table view. The table view section headers are used as tappable areas to collapse rows - just tap a section header, and all of the rows under that section will open below the header and viceversa.

The module is made to be very easy to use and no modifications are necessary to achieve the default behaviour. Just build a table view with cells and section headers and subclass the classes in this module.

FZAccordionTableView Class:

class FZAccordionTableView: UITableView {

    var allowMultipleSectionsOpen: Bool
    var keepOneSectionOpen: Bool
    var initialOpenSections: Set<NSNumber>?
    var enableAnimationFix: Bool

    func isSectionOpen(_ section: Int) -> Bool
    func toggleSection(_ section: Int)
    func section(forHeaderView headerView: UITableViewHeaderFooterView) -> Int

}

FZAccordionTableViewHeaderView Class:

class FZAccordionTableViewHeaderView : UITableViewHeaderFooterView { 

}

FZAccordionTableViewDelegate Protocol:

protocol FZAccordionTableViewDelegate: NSObjectProtocol {

    func tableView(_ tableView: FZAccordionTableView, canInteractWithHeaderAtSection section: Int) -> Bool

    func tableView(_ tableView: FZAccordionTableView, willOpenSection section: Int, withHeader header: UITableViewHeaderFooterView?)
    func tableView(_ tableView: FZAccordionTableView, didOpenSection section: Int, withHeader header: UITableViewHeaderFooterView?)

    func tableView(_ tableView: FZAccordionTableView, willCloseSection section: Int, withHeader header: UITableViewHeaderFooterView?)
    func tableView(_ tableView: FZAccordionTableView, didCloseSection section: Int, withHeader header: UITableViewHeaderFooterView?)
    
}

How To Use?

Steps:

  1. Add to Podfile: pod 'FZAccordionTableView', '~> 0.2.3'
  2. Subclass your UITableView with FZAccordionTableView
  3. Subclass your UITableViewHeaderFooterView with FZAccordionTableViewHeaderView

Example

How Does it Work?

FZAccordionTableView acts as an intermediator between your implementation of UITableViewDelegate/UITableViewDataSource and UITableView. FZAccordionTableView implements UITableViewDelegate and UITableViewDataSource, asks you how many rows you want to display, and reports a different amount to UITableView if a particular section is "closed." Subclassing of UITableViewHeaderFooterView lets FZAccordionTableView know when a particular section is being "opened" or "closed."

License

FZAccordionTableView is released under the MIT license. See LICENSE for details.

You can’t perform that action at this time.