Skip to content
RevealingTableViewCell is a UITableViewCell that can be swiped to reveal content underneath its main view
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
Example
RevealingTableViewCell.xcodeproj
RevealingTableViewCell Version bump to 1.0.9 Oct 5, 2018
Screenshots
docs
.gitignore
.travis.yml
CHANGELOG.md
LICENSE
Package.swift
README.md
RevealingTableViewCell.podspec

README.md

RevealingTableViewCell

Travis CocoaPods Carthage compatible license MIT Swift 4.2


What is it?Check it outInstallationUsageDocumentation

What is it?

RevealingTableViewCell is a UITableViewCell that can be swiped to reveal content underneath its main view.

  • Zero-code setup: RevealingTableViewCell can be set up through Interface Builder, with no code changes.
  • 'Bring your own views' - Note that RevealingTableViewCell does not provide anything other than the sliding view - it's up to you to set up any views that need be revealed, e.g. buttons etc.)

Check it out

CocoaPods

pod try RevealingTableViewCell

(this command clones the example project in a temporary folder and opens it in Xcode)

Directly from the repo

Clone or download this repository and then open Example/RevealingTableViewCellExample.xcodeproj.

Demo video

Click to see an example

(opens in YouTube)

Installation

Requires: iOS 10 +

CocoaPods (recommended)

pod 'RevealingTableViewCell'

Carthage

github "sovata8/RevealingTableViewCell"

Usage

No code changes required, everything is done in Interface Builder.
Note that this framework does not provide anything other than the sliding view - it's up to you to set up any views that need be revealed (e.g. buttons, additional information etc.).

These screenshots show how to set up your views and IBOutlets:

Step 1

Use RevealingTableViewCell (or your subclass of it) as a custom class for your tableview cell in Interface Builder.

Step 2

Inside the cell's default contentView, put a subview and connect it to the the IBOutlet uiView_mainContent. This will be the view that slides sideways to reveal some content underneath. Using AutoLayout, pin this uiView_mainContent to it's superview (the contentView) using the following constraints:

uiView_mainContent.centerX = superview.centerX uiView_mainContent.width = superview.width uiView_mainContent.height = superview.height uiView_mainContent.centerY = superview.centerY

(or instead of the height and centerY constraints, you can use top and bottom constraints)

Step 3

Inside the cell's default contentView, put and connect uiView_revealedContent_left and/or uiView_revealedContent_right subviews. Pin them using AutoLayout to the corresponding sides of your cell. Fix their widths. Make sure they are behind the uiView_mainContent.

Step 4

That's all - run your app!

Making the cells close when needed (optional)

Usually, you would want cells to automatically close whenever you scroll the tableview, or when another cell is swiped sideways. To achieve this, use the provided tableview extension function closeAllCells(exceptThisOne:). Here is an example (from the example project):

// Close all cells when the tableview starts scrolling vertically
extension ViewController: UIScrollViewDelegate
{
    func scrollViewDidScroll(_ scrollView: UIScrollView)
    {
        self.uiTableView.closeAllCells()
    }
}
// Close all other cells when a particular cell starts being swiped
extension ViewController: RevealingTableViewCellDelegate
{
    func didStartPanGesture(cell: RevealingTableViewCell)
    {
        self.uiTableView.closeAllCells(exceptThisOne: cell)
    }
}

(of course when you are creating the cell in your cellForRowAt indexPath logic, don't forget to set the delegate like this: cell.revealingCellDelegate = self)

Documentation

Check out the auto-generated Documentation.
(If you're reading this on GitHub, and the above link opens the html source, try this)

Used by

PivotList Logo
PivotList

Please let me know if you use RevealingTableViewCell in your app and would like to be mentioned here. (either email me or create e new issue with the "usedby" label)

Known limitations and considerations

The way this library works requires that all the 'hidden' views (the ones that are behind the main view and are revealed when sliding), are in the view hierarchy of the cell at all times, even if they are never shown. This is obviously not great when performance matters.

License

This project is licensed under the terms of the MIT license. See the LICENSE file.

You can’t perform that action at this time.