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.
Initial loading:
Pull-to-refresh:
Load more:
Initial load error:
Load more error:
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?
Add this to your Podfile.
pod 'StatefulTableView', '0.1.7'
Pull Requests for fixes and additional functionalities are always welcome. Contributions to the project's roadmap are also appreciated.
- Swift 4