Git Product home page Git Product logo

fzaccordiontableview's Introduction

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.

fzaccordiontableview's People

Contributors

jeffaburt avatar kfuchs avatar kgaidis avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.