• Stars
    star
    176
  • Rank 216,987 (Top 5 %)
  • Language
    Objective-C
  • License
    MIT License
  • Created over 10 years ago
  • Updated over 7 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

UITableViewCell subclass to add multiple buttons to a swipe-under menu like iOS 7 Mail.

DNSSwipeableTableCell


DNSSwipeableTableCell demo

This is an extension of a tutorial I wrote for RayWenderlich.com on how to create a swipeable UITableViewCell for iOS 7 without driving yourself completley insane with UIScrollViews. (Drive yourself insane with constraints instead!)

The crux of the problem is that while adding a delete button is super-easy, adding a delete button AND another button is a total nightmare because of the way the cells are constructed.

I've refactored the code that was included in the tutorial, which is is more meant as an exercise in helping n00bs dive into figuring out how Apple's code works under the hood, into this library, which I'm hoping will be helpful for anyone dealing with this in production code.

The Biggest Changes

  • Removed dependency on the storyboard (though you can still use one if you like)
  • Made the myContentView public so the cell could be subclassed and recycled more easily.
  • Beefed up delegate to handle an arbitrary number of buttons
  • Added datasource to allow tons of user-configurable options
  • Tweaked the animation so it uses spring damping instead of trying to do that manually
  • Added a ton of documentation to the swipeable cell class
  • Cleaned up the sample app quite a bit
  • Added a sample subclass.
  • Added a bunch of photos of my cat, because the internet loves cats.

Notes on Usage

  • If you're using an accessory view via accessoryType, that view will automatically be removed and replaced when the cell is opened and closed (respectively).
  • If you're using a custom background color for your myContentView along with an accessory, remember to set that same color as the background color for the cell itself, or the accessory's going to have a different background color.
  • If you're using a cell from a storyboard or a .xib, you have to add a myContentView view, and hook up the NSLayoutConstraint outlets to the left and right constraints. See the sample project for an example of how to set this up.
  • If you're using a cell from a storyboard or a .xib, make sure you're sending any calls to the superclass during setup which need myContentView to not be nil through awakeFromNib instead of initWithCoder:, since the IBOutlet won't be hooked up until awakeFromNib has fired.

//TODOs

  • Support for swiping in both directions (issue)
  • Support for iOS 8 style cell actions (issue)
  • ??? - File an issue!

Additional Contributors

  • Mark Flowers - Improved fixes for tableview slop, removed index path hack, defaults for numerous previously required methods, and better delegate methods.

Photos

All photos Copyright Ellen Shapiro. If you want to see more photos of my jerkface cat, Chaplin, follow me on Instagram.

More Repositories

1

iOS10NotificationSample

Sample code for my talk about iOS 10 notifications
Swift
105
star
2

DNSCastroSegmentedControl

A segmented control based on the one in the Castro Podcast app's settings page.
Objective-C
38
star
3

GoCubs

A demonstration app for iOS UI testing tools and techniques.
Swift
20
star
4

Wino

Android Wine-Tasting Note Taker / Example App for Testing Talk
Java
19
star
5

KotlinNativeTest

Wee sandbox for playing with Kotlin/Native
Objective-C
14
star
6

TestingWorkshop

Testing workshop code for Swift Aveiro + Swift Alps 2017
Swift
13
star
7

StupidEnumTricks

Code from my talk about Stupid Enum Tricks in Swift and Kotlin
Swift
11
star
8

ProtocolPlayground

Some examples from my dotSwift talk about protocols.
Swift
9
star
9

Xcode8ExtensionExample

An example of how to set up extensions in Xcode 8
Swift
8
star
10

AndroidListenerExamples

Java
7
star
11

TravelPlanner

A travel planning app for demoing Siri Shortcutsβ„’
Swift
7
star
12

LocalizationExplained

Code samples from my 360iDev 2015 / CocoaConf Chicago 2016 talk on localization
Swift
6
star
13

Plister

SPM-based helper for working with Plists at the command line
Swift
5
star
14

MoveItMoveIt

An app about moving with a server-side swift backend
Swift
5
star
15

TestingPlayground

A sample app for unit test demos in my Practical Unit Testing talk.
Objective-C
4
star
16

DatedImageGenerator

A plugin to generate dates images were originally created with relevant image names
Swift
4
star
17

FileARadar

Sample projects for some Radars I've filed
Swift
4
star
18

PanoramaRama

An app showing off some panoramas I took and/or some neat stuff you can do scripting with Swift Package Manager
Swift
4
star
19

WrongWay

A project for https://stupidhackath.no/
Swift
3
star
20

RadioactiveCat

An app to demonstrate SPM code generation (and tell you which cat is radioactive in photos)
Swift
3
star
21

DNSiOSLocalizationTestHelpers

Because testing your iOS app in different languages is a giant pain in the ass.
Objective-C
3
star
22

OperationComparison

Comparing various ways of doing things asynchronously in iOS
Swift
3
star
23

LocalizedKeyGenerator

A Swift Package for generating enums based on your localized string file(s).
Swift
2
star
24

EasingExample

An example application demonstrating how various types of easing work.
Swift
2
star
25

DNSInAppPurchaseManager

A simple IAP manager for iOS.
Objective-C
2
star
26

LOLJS

Electron workshop at Swift Alps 2017
JavaScript
1
star
27

FlickrSearcher

RWDevCon example for the XCTest In Practice session
HTML
1
star
28

BrowserChooser

Code to support letting your users choose between opening links in Google Chrome or Mobile Safari.
Objective-C
1
star
29

MehHTTP

An example Swift Package with an Xcode 12 Playground for documentation
Swift
1
star