From 045ad9b26b6d419b8123069db8dd8b407c935dfc Mon Sep 17 00:00:00 2001 From: Ali Karagoz Date: Sat, 18 Jul 2015 12:57:25 +0200 Subject: [PATCH] Updated README with new installation instructions --- README.md | 90 +++++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 64 insertions(+), 26 deletions(-) diff --git a/README.md b/README.md index 5e16818..1e070cd 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ MCSwipeTableViewCell

-An Effort to show how one would implement a TableViewCell like the one we can see in the very well executed [Mailbox](http://www.mailboxapp.com/) iOS app. +An Effort to show how one would implement a TableViewCell like the one we can see in the very well executed [Mailbox](http://www.mailboxapp.com/) iOS app. ##Demo ###Exit Mode @@ -24,59 +24,59 @@ Please refer to the header file [`MCSwipeTableViewCell.h`](MCSwipeTableViewCell/ ```objc - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"Cell"; - + MCSwipeTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; - + if (!cell) { cell = [[MCSwipeTableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier]; - + // Remove inset of iOS 7 separators. if ([cell respondsToSelector:@selector(setSeparatorInset:)]) { cell.separatorInset = UIEdgeInsetsZero; } - + [cell setSelectionStyle:UITableViewCellSelectionStyleGray]; // Setting the background color of the cell. cell.contentView.backgroundColor = [UIColor whiteColor]; } - + // Configuring the views and colors. UIView *checkView = [self viewWithImageName:@"check"]; UIColor *greenColor = [UIColor colorWithRed:85.0 / 255.0 green:213.0 / 255.0 blue:80.0 / 255.0 alpha:1.0]; - + UIView *crossView = [self viewWithImageName:@"cross"]; UIColor *redColor = [UIColor colorWithRed:232.0 / 255.0 green:61.0 / 255.0 blue:14.0 / 255.0 alpha:1.0]; - + UIView *clockView = [self viewWithImageName:@"clock"]; UIColor *yellowColor = [UIColor colorWithRed:254.0 / 255.0 green:217.0 / 255.0 blue:56.0 / 255.0 alpha:1.0]; - + UIView *listView = [self viewWithImageName:@"list"]; UIColor *brownColor = [UIColor colorWithRed:206.0 / 255.0 green:149.0 / 255.0 blue:98.0 / 255.0 alpha:1.0]; - + // Setting the default inactive state color to the tableView background color. [cell setDefaultColor:self.tableView.backgroundView.backgroundColor]; - + [cell.textLabel setText:@"Switch Mode Cell"]; [cell.detailTextLabel setText:@"Swipe to switch"]; - + // Adding gestures per state basis. [cell setSwipeGestureWithView:checkView color:greenColor mode:MCSwipeTableViewCellModeSwitch state:MCSwipeTableViewCellState1 completionBlock:^(MCSwipeTableViewCell *cell, MCSwipeTableViewCellState state, MCSwipeTableViewCellMode mode) { NSLog(@"Did swipe \"Checkmark\" cell"); }]; - + [cell setSwipeGestureWithView:crossView color:redColor mode:MCSwipeTableViewCellModeSwitch state:MCSwipeTableViewCellState2 completionBlock:^(MCSwipeTableViewCell *cell, MCSwipeTableViewCellState state, MCSwipeTableViewCellMode mode) { NSLog(@"Did swipe \"Cross\" cell"); }]; - + [cell setSwipeGestureWithView:clockView color:yellowColor mode:MCSwipeTableViewCellModeSwitch state:MCSwipeTableViewCellState3 completionBlock:^(MCSwipeTableViewCell *cell, MCSwipeTableViewCellState state, MCSwipeTableViewCellMode mode) { NSLog(@"Did swipe \"Clock\" cell"); }]; - + [cell setSwipeGestureWithView:listView color:brownColor mode:MCSwipeTableViewCellModeSwitch state:MCSwipeTableViewCellState4 completionBlock:^(MCSwipeTableViewCell *cell, MCSwipeTableViewCellState state, MCSwipeTableViewCellMode mode) { NSLog(@"Did swipe \"List\" cell"); }]; - + return cell; } ``` @@ -108,9 +108,9 @@ In `MCSwipeTableViewCellModeExit` mode you may want to delete the cell with a ni ```objc [cell setSwipeGestureWithView:crossView color:redColor mode:MCSwipeTableViewCellModeExit state:MCSwipeTableViewCellState2 completionBlock:^(MCSwipeTableViewCell *cell, MCSwipeTableViewCellState state, MCSwipeTableViewCellMode mode) { NSLog(@"Did swipe \"Cross\" cell"); - - // Code to delete your cell. - [] + + // Code to delete your cell... + }]; ``` @@ -122,10 +122,10 @@ __weak MCTableViewController *weakSelf = self; [cell setSwipeGestureWithView:crossView color:redColor mode:MCSwipeTableViewCellModeExit state:MCSwipeTableViewCellState1 completionBlock:^(MCSwipeTableViewCell *cell, MCSwipeTableViewCellState state, MCSwipeTableViewCellMode mode) { NSLog(@"Did swipe \"Cross\" cell"); - + __strong MCTableViewController *strongSelf = weakSelf; strongSelf.cellToDelete = cell; - + UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Delete?" message:@"Are you sure your want to delete the cell?" delegate:self @@ -140,7 +140,7 @@ Then handle the `UIAlertView` action: #pragma mark - UIAlertViewDelegate - (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex { - + // No if (buttonIndex == 0) { [_cellToDelete swipeToOriginWithCompletion:^{ @@ -148,11 +148,10 @@ Then handle the `UIAlertView` action: }]; _cellToDelete = nil; } - + // Yes else { - // Code to delete your cell. - [...] + // Code to delete your cell... } } ``` @@ -168,7 +167,7 @@ cell.secondTrigger = 0.5; ``` ###Reseting cell position -It is possible to put the cell back to it's position when using the `MCSwipeTableViewCellModeExit` mode with the `-swipeToOriginWithCompletion:` method: +It is possible to put the cell back to it's position when using the `MCSwipeTableViewCellModeExit` mode with the `-swipeToOriginWithCompletion:` method: ```objc [cell swipeToOriginWithCompletion:^{ @@ -176,6 +175,45 @@ It is possible to put the cell back to it's position when using the `MCSwipeTabl }]; ``` +## Installation + +### CocoaPods + +[CocoaPods](http://cocoapods.org) is a dependency manager for Cocoa projects. + +```bash +$ gem install cocoapods +``` + +To integrate MCSwipeTableViewCell into your Xcode project using CocoaPods, specify it in your `Podfile`: + +```ruby +pod 'MCSwipeTableViewCell', '~> 2.1.4' +``` + +Then, run the following command: + +```bash +$ pod install +``` + +### Carthage + +[Carthage](https://github.com/Carthage/Carthage) is a decentralized dependency manager that automates the process of adding frameworks to your Cocoa application. + +You can install Carthage with [Homebrew](http://brew.sh/) using the following command: + +```bash +$ brew update +$ brew install carthage +``` + +To integrate MCSwipeTableViewCell into your Xcode project using Carthage, specify it in your `Cartfile`: + +```ogdl +github "alikaragoz/MCSwipeTableViewCell" >= 2.1.4 +``` + ##Compatibility This library is not compatible with auto-layout so you will need to disable auto-layout in your xib properties.