Skip to content

Custom UITableView container class that supports pull-to-refresh, load-more, initial load, and empty states.

License

Notifications You must be signed in to change notification settings

timominous/StatefulTableView

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

145 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

StatefulTableView

Version License Platform Platform Build Status

Custom UITableView container class that supports pull-to-refresh, load-more, initial load, and empty states. This library aims to be a drop in replacement for UITableView. Swift port of SKStatefulTableViewController.

This is a work in progress. A lot of things may break as of the moment.

Screenshots

Initial loading:

Pull-to-refresh:

Load more:

Initial load error:

Load more error:

Usage

Currently, you can only assign the delegates and data source through code.

tableView.dataSource = self // Confofrms to UITableViewDataSource
tableView.delegate = self // Conforms to UITableViewDelegate
tableView.statefulDelegate = self // Conforms to StatefulTableDelegate

For initial loading, pull-to-refresh, and load more, you have to implement the following statefulDelegate methods:

func statefulTableViewWillBeginInitialLoad(tvc: StatefulTableView, handler: InitialLoadCompletionHandler)
func statefulTableViewWillBeginLoadingFromRefresh(tvc: StatefulTableView, handler: InitialLoadCompletionHandler)
func statefulTableViewWillBeginLoadingMore(tvc: StatefulTableView, handler: LoadMoreCompletionHandler)

To show custom views, return them through the following statefulDelegate methods. Otherwise, return nil.

func statefulTableViewViewForInitialLoad(tvc: StatefulTableView) -> UIView?
func statefulTableViewInitialErrorView(tvc: StatefulTableView, forInitialLoadError: NSError?) -> UIView?
func statefulTableViewLoadMoreErrorView(tvc: StatefulTableView, forLoadMoreError: NSError?) -> UIView?

Installation

Cocoapods

Add this to your Podfile.

pod 'StatefulTableView', '0.1.7'

Contibuting

Pull Requests for fixes and additional functionalities are always welcome. Contributions to the project's roadmap are also appreciated.

TODO

  • Swift 4

Credits

About

Custom UITableView container class that supports pull-to-refresh, load-more, initial load, and empty states.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 3

  •  
  •  
  •