Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/xtrinch/mrpulltorefreshloadmore

Easy and simple way to add pull to refresh and load more for table views, collection views and even scrollviews
https://github.com/xtrinch/mrpulltorefreshloadmore

Last synced: 2 months ago
JSON representation

Easy and simple way to add pull to refresh and load more for table views, collection views and even scrollviews

Awesome Lists containing this project

README

        

# MRPullToRefreshLoadMore

[![CI Status](http://img.shields.io/travis/xtrinch/MRPullToRefreshLoadMore.svg?style=flat)](https://travis-ci.org/xtrinch/MRPullToRefreshLoadMore)
[![Version](https://img.shields.io/cocoapods/v/MRPullToRefreshLoadMore.svg?style=flat)](http://cocoapods.org/pods/MRPullToRefreshLoadMore)
[![License](https://img.shields.io/cocoapods/l/MRPullToRefreshLoadMore.svg?style=flat)](http://cocoapods.org/pods/MRPullToRefreshLoadMore)
[![Platform](https://img.shields.io/cocoapods/p/MRPullToRefreshLoadMore.svg?style=flat)](http://cocoapods.org/pods/MRPullToRefreshLoadMore)

Pull to refresh and load more loader with delegate methods for UITableViews, UICollectionViews (and planned: UIScrollviews). Its usage is extremely simple as it onnly requires setting a class on your uiview. Example project contains tableview and horizontally scrolling collectionview.

## Example

To run the example project, clone the repo, and run `pod install` from the Example directory first.

Pull to refresh a table view:

Load more in a table view:

Pull to refresh in horizontally scrolling collection view:

## Usage

import MRPullToRefreshLoadMore

class ViewController: UIViewController, UITableViewDataSource, UITableViewDelegate, MRPullToRefreshLoadMoreDelegate {

@IBOutlet weak var tableView: MRTableView!

override func viewDidLoad() {
super.viewDidLoad()
tableView.delegate = self
tableView.dataSource = self
tableView.pullToRefresh.pullToRefreshLoadMoreDelegate = self
}

// MARK: MRPullToRefreshLoadMoreDelegate functions

func viewShouldRefresh(scrollView:UIScrollView) {
// if you need a tableview instance
guard let tableView = scrollView as? MRTableView else {
return
}

// refresh table view

tableView.reloadData()
tableView.pullToRefresh.setPullState(MRPullToRefreshLoadMore.ViewState.Normal)

}

func viewShouldLoadMore(scrollView:UIScrollView) {
// if you need a tableview instance
guard let tableView = scrollView as? MRTableView else {
return
}

// load more

tableView.reloadData()
tableView.pullToRefresh.setLoadMoreState(MRPullToRefreshLoadMore.ViewState.Normal)
}
}

Available classes: MRTableView, MRCollectionView

## Installation

MRPullToRefreshLoadMore is available through [CocoaPods](http://cocoapods.org). To install
it, simply add the following line to your Podfile:

```ruby
pod "MRPullToRefreshLoadMore"
```

## Issues && Todo

- Need to disable refresh / load more if either of them is already under way
- Add scrollview support

## Author

xTrinch, [email protected]

## License

MRPullToRefreshLoadMore is available under the MIT license. See the LICENSE file for more info.