Giter Site home page Giter Site logo

pjryan93 / fzaccordiontableview Goto Github PK

View Code? Open in Web Editor NEW

This project forked from ml-opensource/fzaccordiontableview

0.0 3.0 0.0 360 KB

FZAccordionTableView transforms your regular UITableView into an accordion table view.

License: MIT License

Objective-C 93.17% Swift 5.96% Ruby 0.88%

fzaccordiontableview's Introduction

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:

@interface FZAccordionTableView : UITableView

@property (nonatomic) BOOL allowMultipleSectionsOpen;
@property (nonatomic) BOOL keepOneSectionOpen;
@property (strong, nonatomic, nullable) NSSet <NSNumber *> *initialOpenSections;
@property (nonatomic) BOOL enableAnimationFix;

- (BOOL)isSectionOpen:(NSInteger)section;
- (void)toggleSection:(NSInteger)section;
- (NSInteger)sectionForHeaderView:(UITableViewHeaderFooterView *)headerView;

@end

FZAccordionTableViewHeaderView Class:

@interface FZAccordionTableViewHeaderView : UITableViewHeaderFooterView
@end

FZAccordionTableViewDelegate Protocol:

@protocol FZAccordionTableViewDelegate <NSObject>

- (BOOL)tableView:(FZAccordionTableView *)tableView canInteractWithHeaderAtSection:(NSInteger)section;

- (void)tableView:(FZAccordionTableView *)tableView willOpenSection:(NSInteger)section withHeader:(UITableViewHeaderFooterView *)header;
- (void)tableView:(FZAccordionTableView *)tableView didOpenSection:(NSInteger)section withHeader:(UITableViewHeaderFooterView *)header;
- 
- (void)tableView:(FZAccordionTableView *)tableView willCloseSection:(NSInteger)section withHeader:(UITableViewHeaderFooterView *)header;
- (void)tableView:(FZAccordionTableView *)tableView didCloseSection:(NSInteger)section withHeader:(UITableViewHeaderFooterView *)header;

@end

How To Use?

Steps:

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

Swift Support

FZAccordionTableView works with Swift! Check out the Swift Example in the "Example" folder to see FZAccordionTableView implemented in a Swift project.

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

kgaidis avatar pjryan93 avatar

Watchers

 avatar  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.