Coder Social home page Coder Social logo

janak-nirmal / rmswipetableviewcell Goto Github PK

View Code? Open in Web Editor NEW

This project forked from runmad/rmswipetableviewcell

0.0 2.0 0.0 491 KB

RMSwipeTableViewCell is a drop-in UITableViewCell subclass that supports pan gestures as seen in apps such as Clear, Mailbox, Sparrow and many more.

License: MIT License

rmswipetableviewcell's Introduction

#RMSwipeTableViewCell

RMSwipeTableViewCell is a drop-in UITableViewCell subclass that supports pan gestures as seen in apps such as Clear, Mailbox, Sparrow and many more.

RMSwipeTableViewCell allows for easy subclassing to customize the cell to match your needs. The class exposes useful class methods and uses delegate callbacks to handle actions in your UITableViewController.

RMSwipeTableViewCell works great out of the box, but has many properties to customize how the user interacts with the cell.

RMSwipeTableViewCellDemo Screenshot

Video example

##Installing RMSwipeTableViewCell

Add RMSwipeTableViewCell.h and RMSwipeTableViewCell.m to your project. Import the class header and register the cell class in your UITableView.

#import "RMSwipeTableViewCell.h"
// add <RMSwipeTableViewCellDelegate> in your header file if you want to received delegate callbacks on the cell interactions

-(void)viewDidLoad {
    [super viewDidLoad];
    [self.tableView registerClass:[RMSwipeTableViewCell class] forCellReuseIdentifier:CellIdentifier];
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    static NSString *CellIdentifier = @"Cell";
    RMPersonTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
    cell.delegate = self; // optional
    return cell;
}

##Using RMSwipeTableViewCell

RMSwipeTableViewCell can be used as-is, but you are required to customize the backView with subviews, etc. to suit your needs (see Subclassing RMSwipeTableViewCell).

The RMSwipeTableViewCellDemo project provides an example of subclassing and customizing the cell with custom views and actions.

###Properties

RMSwipeTableViewCell lets you customize and control animations and panning gestures. The demo uses all default states.

UIView *backView;
RMSwipeTableViewCellRevealDirection revealDirection; // default is RMSwipeTableViewCellRevealDirectionBoth
RMSwipeTableViewCellAnimationType animationType; // default is RMSwipeTableViewCellAnimationTypeBounce
float animationDuration; // default is 0.2
BOOL revealsBackground; // default is NO
BOOL shouldAnimateCellReset; // this can be overriden at any point (useful in the swipeTableViewCellWillResetState:fromLocation: delegate method). default is YES - note: it will reset to YES in prepareForReuse
BOOL panElasticity; // When panning/swiping the cell's location is set to exponentially decay. The elsticity/stickiness closely matches that of a UIScrollView/UITableView. default is YES
UIColor *backViewbackgroundColor; // default is [UIColor colorWithWhite:0.92 alpha:1]

##Subclassing RMSwipeTableViewCell

Subclassing RMSwipeTableViewCell is the best way to customize the cell beyond the default properties and any delegate callbacks. Subclassing allows you to create subviews for the backView, extend properties if needed and override class methods.

See the demo for an example of subclassing usage.

##RMSwipeTableViewCell Delegate Methods

RMSwipeTableViewCell has a number of (optional) delegate methods that provide an extensive. The delegate methods are fairly verbose and the demo project shows a few examples of usage.

// notifies the delegate when the user starts panning
-(void)swipeTableViewCellDidStartSwiping:(RMSwipeTableViewCell*)swipeTableViewCell;

// notifies the delegate when the panning location changes
-(void)swipeTableViewCell:(RMSwipeTableViewCell*)swipeTableViewCell swipedToLocation:(CGPoint)translation velocity:(CGPoint)velocity;

// notifies the delegate when the user lifts their finger from the screen and cell will reset
-(void)swipeTableViewCellWillResetState:(RMSwipeTableViewCell*)swipeTableViewCell fromLocation:(CGPoint)translation animation:(RMSwipeTableViewCellAnimationType)animation velocity:(CGPoint)velocity;

// notifies the delegate when the cell has reset itself back to its starting state. This is useful for doing further animation or updates on the cell after the reset animation has completed
-(void)swipeTableViewCellDidResetState:(RMSwipeTableViewCell*)swipeTableViewCell fromLocation:(CGPoint)translation animation:(RMSwipeTableViewCellAnimationType)animation velocity:(CGPoint)velocity;

##Credit

Developed by Rune Madsen (@runmad and runmad.com).

##Feedback

I appreciate feedback. Create Github issues, pull requests or connect with me on Twitter.

I'd love to see and hear from you if you use it in a project.

##License

RMSwipeTableViewCell is available under the MIT license. See the LICENSE file for more info.

rmswipetableviewcell's People

Contributors

runmad avatar

Watchers

James Cloos avatar Janak Nirmal 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.