Giter Site home page Giter Site logo

mohsinalimat / revealingtableviewcell Goto Github PK

View Code? Open in Web Editor NEW

This project forked from sovata8/revealingtableviewcell

1.0 2.0 0.0 1.39 MB

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

License: MIT License

Swift 81.27% Ruby 16.92% Objective-C 1.81%

revealingtableviewcell's Introduction

RevealingTableViewCell

Travis Swift 3.0 license MIT CocoaPods CocoaPods Carthage compatible


What is it?Check it outInstallationUsage

What is it?

RevealingTableViewCell is a UITableViewCell that can be swiped to reveal content underneath its main view.
It can be set up through Interface Builder, with no code changes.
It does not provide anything other than the sliding view - it's up to you to set up any views that need be revealed.

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: Swift 3, iOS 10

CocoaPods (recommended)

pod 'RevealingTableViewCell'
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 using 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.

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 specify that cell.revealingCellDelegate = self)

Known issues and considerations

  • At the moment it is required 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.

revealingtableviewcell's People

Contributors

sovata8 avatar

Stargazers

MohsinAli avatar

Watchers

MohsinAli avatar  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.