Giter Site home page Giter Site logo

iamimsh / tbemptydataset Goto Github PK

View Code? Open in Web Editor NEW

This project forked from teambition/tbemptydataset

0.0 2.0 0.0 801 KB

An extension of UITableView/UICollectionView's super class, it will display a placeholder emptyDataSet when the data of tableView/collectionView is empty.

License: MIT License

Swift 98.69% Ruby 1.31%

tbemptydataset's Introduction

TBEmptyDataSet

TBEmptyDataSet is an extension of UITableView/UICollectionView's super class, it will display a placeholder emptyDataSet when the data of tableView/collectionView is empty.

TBEmptyDataSet can be composed of an image, a title and a description, or you can set it as a custom view.

Example

How To Get Started

Carthage

Specify "TBEmptyDataSet" in your Cartfile:

github "teambition/TBEmptyDataSet"

CocoaPods

Specify "TBEmptyDataSet" in your Podfile:

source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.0'
use_frameworks!

pod 'TBEmptyDataSet'

Usage

1. Assign the data source and delegate
tableView.emptyDataSetDataSource = self
tableView.emptyDataSetDelegate = self
2. Implement the data source and delegate

Data source functions:

func imageForEmptyDataSet(in scrollView: UIScrollView) -> UIImage? {
    // return the image for EmptyDataSet
}

func titleForEmptyDataSet(in scrollView: UIScrollView) -> NSAttributedString? {
    // return the title for EmptyDataSet
}

func descriptionForEmptyDataSet(in scrollView: UIScrollView) -> NSAttributedString? {
    // return the description for EmptyDataSet
}

func imageTintColorForEmptyDataSet(in scrollView: UIScrollView) -> UIColor? {
    // return the image tint color for EmptyDataSet
}

func backgroundColorForEmptyDataSet(in scrollView: UIScrollView) -> UIColor? {
    // return the backgroundColor for EmptyDataSet
}

func verticalOffsetForEmptyDataSet(in scrollView: UIScrollView) -> CGFloat {
    // return the vertical offset for EmptyDataSet, default is 0
}

func verticalSpacesForEmptyDataSet(in scrollView: UIScrollView) -> [CGFloat] {
    // return the vertical spaces from top to bottom for EmptyDataSet, default is [12, 12]
}

func customViewForEmptyDataSet(in scrollView: UIScrollView) -> UIView? {
    // return an UIView instance for EmptyDataSet
}

Delegate functions:

func emptyDataSetShouldDisplay(in scrollView: UIScrollView) -> Bool {
    // should display EmptyDataSet or not, default is true
}

func emptyDataSetTapEnabled(in scrollView: UIScrollView) -> Bool {
    // enable tap gesture or not, default is true
}

func emptyDataSetScrollEnabled(in scrollView: UIScrollView) -> Bool {
    // scrollView can scroll or not, default is false
}

func emptyDataSetDidTapEmptyView(in scrollView: UIScrollView) {
    // do something
}

func emptyDataSetWillAppear(in scrollView: UIScrollView) {
    // do something
}

func emptyDataSetDidAppear(in scrollView: UIScrollView) {
    // do something
}

func emptyDataSetWillDisappear(in scrollView: UIScrollView) {
    // do something
}

func emptyDataSetDidDisappear(in scrollView: UIScrollView) {
    // do something
}
3. Data source events (inserting, deleting, reloading, etc.)

TBEmptyDataSet will update automatically when the data source of table view or collection view changes.

To be specific:

  • For UITableView, it updates when endUpdates() is called.
  • For UICollectionView, it updates when performBatchUpdates(_:completion:) is completed.
  • For both UITableView and UICollectionView, it updates when reloadData() is called.

Minimum Requirement

iOS 8.0

Release Notes

License

TBEmptyDataSet is released under the MIT license. See LICENSE for details.

More Info

Have a question? Please open an issue!

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.