GithubHelp home page GithubHelp logo

goto10 / seslidetableviewcell Goto Github PK

View Code? Open in Web Editor NEW

This project forked from drallgood/seslidetableviewcell

0.0 1.0 0.0 471 KB

a subclass of UITableViewCell which shows buttons with a swipe gesture

License: MIT License

Ruby 1.01% Objective-C 82.46% Swift 16.53%

seslidetableviewcell's Introduction

SESlideTableViewCell

A subclass of UITableViewCell that shows buttons with swiping it.

Features

  • Portable. Made up with only one header and one source file.
  • Indicator that shows which way you can swipe.
  • Ready for iOS 8.
  • Supports Swift language.

Requirements

SESlideTableViewCell runs on iOS 7 and later. It also works iOS 8 and it can be used in Swift language.

How to Set up

Use CocoaPods to set up SESlideTableViewCell.

platform :ios, "7.0"
pod 'SESlideTableViewCell'

See http://cocoapods.org/ for more information about CocoaPods.

Getting Started with Objective-C

You can create a SESlideTableViewCell in your UITableViewController like this.

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
	NSString * const CELL_ID = @"Cell";
	SESlideTableViewCell* cell = (SESlideTableViewCell*)[tableView dequeueReusableCellWithIdentifier:CELL_ID];
	if (!cell) {
		cell = [[SESlideTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CELL_ID];
		cell.delegate = self;
		[cell addRightButtonWithText:@"Hello" textColor:[UIColor whiteColor] backgroundColor:[UIColor colorWithHue:0.0/360.0 saturation:0.8 brightness:0.9 alpha:1.0]];
		[cell addRightButtonWithText:@"World!!" textColor:[UIColor whiteColor] backgroundColor:[UIColor colorWithHue:180.0/360.0 saturation:0.8 brightness:0.9 alpha:1.0]];
	}
	return cell;
}

You can know which button is triggered with a SESlideTableViewCellDelegate method.

- (void)slideTableViewCell:(SESlideTableViewCell*)cell didTriggerRightButton:(NSInteger)buttonIndex {
	NSLog(@"right button triggered:%d", (int)buttonIndex);
}

Getting Started with Swift

You can create a SESlideTableViewCell in your UITableViewController like this.

override func tableView(tableView: UITableView!, cellForRowAtIndexPath indexPath: NSIndexPath!) -> UITableViewCell? {
	let CELL_ID = "Cell"
	var cell = tableView.dequeueReusableCellWithIdentifier(CELL_ID) as? SESlideTableViewCell
	if !cell {
		cell = SESlideTableViewCell(style: .Default, reuseIdentifier: CELL_ID)
		cell!.delegate = self
		cell!.addRightButtonWithText("Hello", textColor: UIColor.whiteColor(), backgroundColor: UIColor(hue: 0.0/360.0, saturation: 0.8, brightness: 0.9, alpha: 1.0))
		cell!.addRightButtonWithText("World!!", textColor: UIColor.whiteColor(), backgroundColor: UIColor(hue: 180.0/360.0, saturation: 0.8, brightness: 0.9, alpha: 1.0))
	}
	
    return cell
}

You can know which button is triggered with a SESlideTableViewCellDelegate method.

func slideTableViewCell(cell: SESlideTableViewCell!, didTriggerRightButton buttonIndex: NSInteger) {
	let indexPath = tableView.indexPathForCell(cell)
	println("right button \(buttonIndex) tapped in cell \(indexPath.section) - \(indexPath.row)")
}

License

MIT license.

Limitations

The animation of the contents in the cell stops while buttons are displayed. This comes from using snapshot to display the existing content in the cell.

seslidetableviewcell's People

Contributors

goto10 avatar spaceelephant avatar

Watchers

 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.