Giter Club home page Giter Club logo

collapsabletable's Introduction

CollapsableTable Twitter

Carthage compatible Platform

Design

The collapsing mechanism can be installed in just a few minutes. But the creative design and styling of the UI, is at the mercy of the implementing developer. There are a handful of pre-built designs available within the demo target bundle named 'example'. However, after seeing them you may want to implement your own...

Creating your own is simple

Subclass RRNTableViewHeaderFooterView and override the following methods. The follwing implementation is how you might achieve the image rotation example shown by the demo .gif that is running within this readme.

-(void)openAnimated:(BOOL)animated {
    
    if (animated && !isRotating) {
        
        isRotating = YES;
        
        [UIView animateWithDuration:0.2 delay:0.0 options: UIViewAnimationOptionAllowUserInteraction |UIViewAnimationOptionCurveLinear animations:^{
            self.imageView.transform = CGAffineTransformIdentity;
        } completion:^(BOOL finished) {
            isRotating = NO;
        }];
        
    } else {
        [self.layer removeAllAnimations];
        self.imageView.transform = CGAffineTransformIdentity;
        isRotating = NO;
    }
}

-(void)closeAnimated:(BOOL)animated {
    
    if (animated && !isRotating) {
        
        isRotating = YES;
        
        [UIView animateWithDuration:0.2 delay:0.0 options: UIViewAnimationOptionAllowUserInteraction |UIViewAnimationOptionCurveLinear animations:^{
            self.imageView.transform = CGAffineTransformMakeRotation(DEGREES_TO_RADIANS(180.0f));
        } completion:^(BOOL finished) {
            isRotating = NO;
        }];
        
    } else {
        [self.layer removeAllAnimations];
        self.imageView.transform = CGAffineTransformMakeRotation(DEGREES_TO_RADIANS(180.0f));
        isRotating = NO;
    }
}

//Optional
-(void)updateTitle:(NSString *)title {
    self.titleLabel.text = title;
}

Demo

Run each of the supplied XCode schemes.

Installation

Carthage is a decentralized dependency manager that builds your dependencies and provides you with binary frameworks.

You can install Carthage with Homebrew using the following command:

$ brew update
$ brew install carthage

To integrate CollapsableTable.framework into your Xcode project, using Carthage, specify it in your Cartfile:

github "rob-nash/collapsabletable"

Then run carthage update to fetch and build the binary file. To incorporate the file into your project, drag the binary into embedded frameworks. Once the binary is set as an embedded framework, any future versions can be installed by simply running carthage again, without the need to re-introduce the binary to your XCode project. You may want to specify a release and run carthage following controlled cartifle amendments, like so.

github "rob-nash/collapsabletable" == 1.0.0

Official binary releases are declared within the Releases tab.

Usage

  1. Build a UITableView, either in code or from interface builder.
  2. Subclass RRNTableViewHeaderFooterView and override all of it's public methods. Create a nib for this subclass with the same filename.
  3. Subclass RRNCollapsableTableViewController and override all of it's public methods.
Something like this ```objective-c -(UITableView *)collapsableTableView { return self.tableView; }

-(NSString *)sectionHeaderNibName { return NSStringFromClass([CustomSectionHeaderView class]); }

-(NSBundle *)sectionHeaderNibBundle { return [NSBundle bundleForClass:NSClassFromString([self sectionHeaderNibName])]; }

-(NSArray *)menu { if (_menu == nil) { _menu = (NSArray *)[FakeModelBuilder buildMenu]; } return _menu; }

-(NSArray *)model { return self.menu; }

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { return 44.0f; }

-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section { return [CustomSectionHeaderView minimumHeight]; }

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

// id mSection = self.menu[indexPath.section]; // id item = mSection.items[indexPath.row];

return [tableView dequeueReusableCellWithIdentifier:@"Cell"];

}

</details>

### Known issues
If you have > 8,000-10,000 rows in any given table view section, the frame rate drops to a noticable level.

# Licence
The MIT License (MIT)

Copyright (c) 2016 Rob Nash

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

collapsabletable's People

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.