Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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
- Host: GitHub
- URL: https://github.com/xtrinch/mrpulltorefreshloadmore
- Owner: xtrinch
- License: mit
- Created: 2016-07-19T07:02:41.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2016-08-30T22:15:13.000Z (over 8 years ago)
- Last Synced: 2024-10-11T13:42:10.704Z (3 months ago)
- Language: Swift
- Size: 3.83 MB
- Stars: 4
- Watchers: 3
- Forks: 5
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
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.