• This repository has been archived on 30/Jun/2021
  • Stars
    star
    178
  • Rank 214,989 (Top 5 %)
  • Language
    Swift
  • License
    MIT License
  • Created almost 8 years ago
  • Updated over 3 years ago

Reviews

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

Repository Details

An empty state control to give visually appealing context when building iOS applications.

banner

Requirements

  • Xcode 9.0 +
  • iOS 9.0 or greater

Installation

CocoaPods

  1. Install CocoaPods
  2. Add this repo to your Podfile
target 'Example' do
  use_frameworks!
	
  pod 'UIEmptyState'
end
  1. Run pod install
  2. Open up the new .xcworkspace that CocoaPods generated
  3. Whenever you want to use the library: import UIEmptyState

Carthage

  1. Make sure Carthage is install

    brew install carthage

  2. Add this repo to your Cartfile

    github "luispadron/UIEmptyState"

Manually

  1. Simply download the UIEmptyState source files and import them into your project.

Usage

As long as you are using a UIViewController subclass you will get default conformance as well as the reloadEmptyState method.

// No subclassing required, simply conform to the two protocols
class ViewController: UITableViewController, UIEmptyStateDataSource, UIEmptyStateDelegate {
    
    override func viewDidLoad() {
        super.viewDidLoad()
        // Set the data source and delegate
        self.emptyStateDataSource = self
        self.emptyStateDelegate = self
        // Optionally remove seperator lines from empty cells
        self.tableView.tableFooterView = UIView(frame: CGRect.zero)
   }
   
   override func viewDidAppear(_ animated: Bool) {
   	super.viewDidAppear(animated)
	// Set the initial state of the tableview, called here because cells should be done loading by now
	// Number of cells are used to determine if the view should be shown or not
	self.reloadEmptyState()
   }
}

Whenever you need to reload the empty state view for example, on data changes to your table view source, make sure to call self.reloadEmptyState() if inside a UITableViewController or UICollectionViewController. If inside a regular UIViewController make sure to call the appropriate reloadEmptyStateForTableView(_:) or reloadEmptyStateForCollectionView(_:) methods.

Example:

// Inside a UITableViewController subclass

func foo() {
	// My data has changed here, I want to my tableview, 
	// and in case I no longer have data (user deleted, etc) also reload empty view
	self.tableView.reloadData()
	// Reload empty view as well
	self.reloadEmptyState()
}

func deleteFoo() {
	// This works too, just call after end updates
	tableView.beginUpdates()
	fooSource.remove(at: indexPath.row)
	tableView.deleteRows(at: [indexPath], with: .automatic)
	tableView.endUpdates()
	// Call reload of empty state 
	self.reloadEmptyState()
}

If you need more help take a look at the example project here (Pokemon nerds, will like it): Example

Documentation

Read the full documentation here

Example Project

  1. Clone this repo
  2. Change directory into Example
  3. Run pod install

License (MIT)

Copyright (c) 2017 Luis Padron

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

More Repositories

1

UICircularProgressRing

A circular progress bar for iOS written in Swift
Swift
1,725
star
2

LPSnackbar

A flexible and easy to use Snackbar control for iOS.
Swift
78
star
3

LPThumbnailView

A thumbnail view for iOS to give context to multiple images/videos using thumbnails and counter.
Swift
51
star
4

GradePoint

An assignment tracker and GPA calculator app for iOS
Swift
25
star
5

YouTube-Subscription-Importer

Imports subscriptions from one YouTube account to another using Python 3.
Python
15
star
6

BandLoader

Bandcamp downloading GUI tool. [DEPRECATED]
Python
13
star
7

LPIntegratedRating

Integrated rating view for iOS
Swift
7
star
8

Weatherly

Simple weather app for android
Java
3
star
9

Decaf-Lang-Syntax

Visual Studio Code syntax and language support for the Decaf programming language
3
star
10

luispadron

2
star
11

EyeBot

EyeBot
Swift
2
star
12

DailyCodingProblems

Problem solutions for some daily coding problems I either find online or get from dailycodingproblem.com
Swift
2
star
13

rules_playdate

Bazel rules for building Playdate applications in Swift and C.
Starlark
2
star
14

GithubPage

Github Page πŸ¦‘
CSS
1
star
15

Music-Recommender

Recommends music/artists to user, class project.
Java
1
star
16

Payit

Payit: an Android credit card payment reminder
Java
1
star
17

HelloRPG

Hello world RPG game using Godot.
GDScript
1
star
18

snake_game

A Snake clone written with Rust & Bevy!
Rust
1
star
19

Decaf-Lang

Decaf a "language" developed @ University of Michigan
Assembly
1
star
20

bazel-build-event-converter

A Swift command line tool designed for converting Bazel Build Event Protocol.
Starlark
1
star