Giter VIP home page Giter VIP logo

amrefresher's Introduction

Note: This project is no longer maintained.

Version License Platform

AMRefresher

Super easy way to use "Pull To Refresh" and "Infinite Scrolling" with 1 line of code

Installation

SwiftyCodeView is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod 'AMRefresher'

Or

Copy the AMRefresher folder to your project.

Usage

Adding PullToRefresh and InfiniteScrolling to any UIScrollView is pretty easy:

override func viewDidLoad() {
    super.viewDidLoad()

    //Adding Pull To Refresh
    tableView.am.addPullToRefresh { [unowned self] in
        //Do your heavy job.
        //modify your datasource
        //...
        self.tableView.reloadData() //or insert cells at top of tableView
        self.tableView.am.pullToRefreshView?.stopRefreshing()
    }
 
    //Adding Infinite Scrolling
    tableView.am.addInfiniteScrolling { [unowned self] in
        //Do your heavy job.
        //append to your datasource
        //...
        self.tableView.reloadData() //or insert cells at bottom of tableView
        self.tableView.am.infiniteScrollingView?.stopRefreshing()
    }
}

If you’d like to programmatically trigger the refresh (for instance in viewDidAppear:), you can do so with:

tableView.am.pullToRefreshView?.trigger()

IMPORTANT NOTE

If you want to change the contentInset of the ScrollView, do that BEFORE adding pullToRefresh or infiniteScrolling.

Customization

Both AMPullToRefreshView and AMInfiniteScrollingView have public method

public func setCustomView(_ view: UIView, for state: AM.State)

So you can call this method and pass any UIView you want to show for each state.

Author

arturdev, [email protected]

Feel free to open issues, feature requests and point bugs/mistakes!

License

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

amrefresher's People

Contributors

andreiboariu avatar arturdev avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

amrefresher's Issues

Version ObjectiveC

Hello. Can you have version ObjectiveC. I have used MXParallaxHeader version Objective C then i cant pull to refrresh?
Thanks

Buggy pull to refresh control

I compared the usual UIRefreshControl inside UICollectionView with your one. Your one has too jumpy animation. Code example:

collectionView.am.addPullToRefresh {
            DispatchQueue.main.asyncAfter(deadline: .now() + 3) {
//... some code here
}
}

Pull to refresh doesn't work at all for small item count

Usual UIRefreshControl in UICollectionView works always. Your doesn't work when there is not enough items. So in this case I can't reload the table with gestures at all.
So if I need "pull to refresh" and "infinite scrolling" simultaneously I can't use your control - "pull to refresh" doesn't work in some cases and "infinite scrolling" denies using of default UIRefreshControl!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.