Skip to content
This repository has been archived by the owner on Jul 5, 2023. It is now read-only.

A drop-in replacement for UITableViewCell with horizontal scrolling to reveal a custom view, similar to Apple's swipe to delete button.

License

Notifications You must be signed in to change notification settings

DonovanSoderlund/DSSwipeTableViewCell

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DSSwipeTableViewCell

A drop-in replacement for UITableViewCell with horizontal scrolling to reveal a custom view, similar to Apple's swipe to delete button.

Installation

CocoaPods

add pod 'DSSwipeTableViewCell' to your podfile.

Manual

Copy files in DSSwipeTableViewCell/ into your project and import DSSwipeTableViewCell.h in your UITableViewController.

Usage

Use as a drop-in replacement for UITableViewCell. Enable and disable the swipe areas and add content to them.

It's recommended to subclass DSSwipeTableViewCell and setup the areas with buttons etc.

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:UITableViewCellStyleDefault reuseIdentifier:reuseIdentifier];
    if (self) {
        self.leftAreaEnabled = YES;
        self.leftAreaWidth = 100;
        
        self.rightAreaEnabled = YES;
        self.rightAreaWidth = 150;
        
        self.rightArea.backgroundColor = [UIColor colorWithRed:1.00f green:0.23f blue:0.19f alpha:1.00f];
        
        // Adding button
        UIButton *rightButton = [[UIButton alloc] initWithFrame:self.rightArea.bounds];
        // If you plan to use different height cells a resizing mask is recommended.
        rightButton.autoresizingMask = UIViewAutoresizingFlexibleHeight;
        [rightButton addTarget:self action:@selector(rightButtonAction) forControlEvents:UIControlEventTouchUpInside];
        [rightButton setTitle:@"Action" forState:UIControlStateNormal];
        [self.rightArea addSubview:rightButton];
    }
    return self;
}

- (void)rightButtonAction {
    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Action" message:@"Right button was pressed" delegate:self cancelButtonTitle:nil otherButtonTitles:@"OK", nil];
    [alert show];
}

Demo

Screenshot

Requirements

DSSwipeTableViewCell is compatible with iOS 7.0+

Contact

Donovan Söderlund

License

DSSwipeTableViewCell is available under the MIT License (MIT)

About

A drop-in replacement for UITableViewCell with horizontal scrolling to reveal a custom view, similar to Apple's swipe to delete button.

Resources

License

Stars

Watchers

Forks

Packages

No packages published