8000 GitHub - xtrinch/MRPullToRefreshLoadMore: Easy and simple way to add pull to refresh and load more for table views, collection views and even scrollviews
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

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

License

Notifications You must be signed in to change notification settings

xtrinch/MRPullToRefreshLoadMore

Repository files navigation

MRPullToRefreshLoadMore

CI Status Version License Platform

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. To install it, simply add the following line to your Podfile:

pod "MRPullToRefreshLoadMore"

Issues && Todo

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

Author

xTrinch, mojca.rojko@gmail.com

License

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

About

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

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

0