Git Product home page Git Product logo

stcollapsetableview's Introduction

STCollapseTableView

A UITableView subclass that automatically collapse and/or expand your sections.

You just have to fill your datasource like for a classic UITableView and the magic will happen.

How to use it ?

By default all the sections are closed, so no rows will be displayed ! But you have now access to several new table view methods:

- (void)openSection:(NSUInteger)sectionIndex animated:(BOOL)animated;
- (void)closeSection:(NSUInteger)sectionIndex animated:(BOOL)animated;
- (void)toggleSection:(NSUInteger)sectionIndex animated:(BOOL)animated;
- (BOOL)isOpenSection:(NSUInteger)sectionIndex;

As their names suggests, those methods allows to open or close a section and can be animated or not. The last one returns a boolean to know if a section is currently open.

so if you want the first section to be open after your view is loaded, you could write:

- (void)viewDidLoad
{
    [super viewDidLoad];
    
    [self.tableView reloadData];
    [self.tableView openSection:0 animated:NO];
}

By default if you open a section, any other that is open will automatically be closed. This can be prevented by setting this property to NO:

@property (nonatomic, assign) BOOL exclusiveSections;

As you might have seen, your headers automatically toggle theirs section on a tap ! This is automatically done for you in three conditions:

  • Your datasource implements the tableView:heightForHeaderInSection: method
  • The returned views haven't any UITapGestureRecognizer.
  • the STCollapseTableView property shouldHandleHeadersTap is YES (which is the default value).

Installation

To include this component in your project, I recommend you to use Cocoapods:

  • Add pod "STCollapseTableView" to your Podfile.

How does it work ?

Here is an article about how this component works : Forwarding Mechanism.

stcollapsetableview's People

Contributors

isoftom avatar

Watchers

James Cloos 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.