Coder Social home page Coder Social logo

refresher's Introduction

DEPRECATED

This library is no longer maintained. I am not using it in any of my projects, and I, unfortunately, don't have time to maintain it in my free time. Please open an issue if you are willing to become the new maintainer.

Build Status

Refresher is pull to refresh library written in Swift. It provides easy to use UIScrollView methods to add pull to refresh to your view. Refresher also supports custom animations.

Usage

Basic usage

tableView.addPullToRefreshWithAction {
	NSOperationQueue().addOperationWithBlock {
    	sleep(2)
        NSOperationQueue.mainQueue().addOperationWithBlock {
        	self.tableView.stopPullToRefresh()
        }
    }
}

Custom animations

Refresher supports custom animations on PullToRefreshView. You need to create object that conforms to PullToRefreshViewAnimator protocol. Then, just pass your custom animator in addPullToRefrshWithAction:

tableView.addPullToRefreshWithAction({           
  	NSOperationQueue().addOperationWithBlock {
   		sleep(2)
        NSOperationQueue.mainQueue().addOperationWithBlock {
        	self.tableView.stopPullToRefresh()
        }
    }
}, withAnimator: CustomAnimator())

Required methods that your custom object need to implement are:

  • func pullToRefreshAnimationDidStart(view: PullToRefreshView)- Called when user releases finger and when loading actually starts. Start your animations here.
  • func pullToRefreshAnimationDidEnd(view: PullToRefreshView) - Called when animation is over. Perform any necessary after animation cleanup here.
  • func pullToRefresh(view: PullToRefreshView, progressDidChange progress: CGFloat) - Called while user is pulling scroll view. Useful if you want to implement some kind of progress like behaviour.
  • func pullToRefresh(view: PullToRefreshView, stateDidChange state: PullToRefreshViewState) - Called when PullToRefreshView changes its state

Custom views

You can use your own custom UIView subclass as pull to refresh view.

if let customSubview = NSBundle.mainBundle().loadNibNamed("CustomSubview", owner: self, options: nil).first as? CustomSubview {
	tableView.addPullToRefreshWithAction({
		NSOperationQueue().addOperationWithBlock {
			sleep(2)
			NSOperationQueue.mainQueue().addOperationWithBlock {
				self.tableView.stopPullToRefresh()
			}
		}
	}, withAnimator: customSubview)
}

Your custom subclass has to conform to PullToRefreshViewDelegate.

Requirements

  • Xcode 6
  • iOS 8.0

Installation

Git submodule

  1. Add Refresher as a git submodule into your top-level project directory or simply copy whole folder
  2. Find PullToRefresh.xcodeproj and drag it into the file navigator of your app project.
  3. In Xcode, navigate to the target configuration window by clicking on the blue project icon, and selecting the application target under the "Targets" heading in the sidebar.
  4. Under "General" panel go to "Linked Frameworks and Libraries" and add Refresher.framework

Framework

  1. Simply download Refresher
  2. Build it and you should find Refresher.framework under "Products" group.
  3. Right click on it and select "Show in Finder" option.
  4. Just drag and drop Refresher.framework to your project

Cocoapods

  1. Add pod 'Refresher' to your Podfile
  2. Run pod install

Examples

Refresher: preview default Refresher: preview beat Refresher: preview pacman

Credits

Refresher is created by Josip Ćavar and inspired by SVPullToRefresh. If you have suggestions or bug reports, feel free to send pull request or create new issue.

refresher's People

Contributors

briv avatar eventualbuddha avatar jcavar avatar liuyaodong 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  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  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  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  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  avatar  avatar  avatar  avatar  avatar

refresher's Issues

Refresher doesn't build for iOS 9 targets

Hi there

Are there any plans for refresher to support iOS 9? After upgrading to Xcode 7.0.1 (which defaults to build against iOS 9), Refresher no longer builds (e.g. in 'AnimatorView' label.setTranslatesAutoresizingMaskIntoConstraints(false) is deprecated in favour of label.translatesAutoresizingMaskIntoConstraints = false).

Cocoapods error

I've installed the framework through Cocoapods. When I build it Xcode presents the following error:

error: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool: unknown option character `X' in: -Xlinker

What might be going on?

Activate refresh by programming ?

Hello,

I have a small question, how to activate the refresh programmatically?

After returning from a function, I would like to update the list and trigger a refresh by code ..
Is it possible ?

Thank you for your help :)

Quick pull will lead to refresh twice or more times.

When I quickly pull the collectionView, the screen will refresh twice or more times. It seems that because the value of "loading" is not updated immediately.
if (scrollView.isDragging == false && loading == false) {
loading = true
}
These codes will be executed many times. Do you have a good method to solve it?

Thanks

Where to put custom load data code?

Where to put custom load/grab data code?

tableView.addPullToRefreshWithAction({
            NSOperationQueue().addOperationWithBlock {
                sleep(2)
                NSOperationQueue.mainQueue().addOperationWithBlock {
                    self.tableView.stopPullToRefresh()
                }
            }
        }, withAnimator: PacmanAnimator())

Is it inside the mainQueue or outside?

Calling StopPullToRefresh doesn't stop Refresher

I copied the files from the demo project in to my own created an animator and set the pull to refresh view but calling stopPullToRefresh doesn't seem to do anything. After setting some breakpoint it seems as if the function is called but the delegate is not called.

There are lots of compile errors after import by cocoapods

My Podfile is as the following:

platform :ios, '8.0'

use_frameworks!

pod "AFNetworking", "> 2.0"
pod "SwiftyJSON", ">= 2.2"
pod 'Alamofire', '
> 1.2'
pod 'SwiftDate'
pod 'Refresher'


After successfully installed the Refresher, there are lots of Compile Error happened. see attached screenshot.
screen shot 2015-06-11 at 5 01 41 pm

How can I use bottom load data?

Dear Jcavar,

I'm using your library but I don't know how can I add bottom load more data.

Please let me know about it

Thank you.

Not support remove method

There is a addPullToRefreshWithAction method to add refresher but there isn't a removePullToRefresh to remove it in some case, someone who implement this would be appreciated

how to acieve pull up to refresh

HI, I found your Examples are refreshed by user pull from the top of the screen.
how to achieve refresh by pull from the bottom of the screen,
I mean how to trigger load more data from server when user pull from bottom when we arrived the end of the tableview or collectionView?

thanks a lot!

Localization

Hey @jcavar ! Great module.
I noticed there are NSLocalizedString's inside your pod. But any idea how can I pull them inside my project for translation?

Refresh action is call twice without calling tableView.startPullToRefresh()

Hi! I have adde the Refresher framework to my project, great work! But I am facing a problem.

I've just added a tableView to a ViewController and create the Outlet, delegate and datasource and on viewDidLoad I have added:

tableView.addPullToRefreshWithAction {
NSOperationQueue().addOperationWithBlock {
sleep(2)
NSOperationQueue.mainQueue().addOperationWithBlock {
self.tableView.stopPullToRefresh()
}
}
}

The problem is that automatically when the view is load, the refresh action is done twice!

I am not calling tableView.startPullToRefresh() at any point of my code, if I had the tableView.startPullToRefresh() on viewDidAppear as in the demo project the refresh action will be ejecute three times!

Any idea of what the problem could be?

Thanks very much for your help

refresherView'position was wrong

use more than one startPullToRefresh(), it will make the wrong contentInset. I found it's wrong in the method startAnimating() with code "var insets = scrollView.contentInset; insets.top += self.frame.size.height"

iOS 7 support

Hi, is there a possibility that you add iOS 7 support to the framework?

If not, which functions would be missing on iOS 7?

It is giving me this warning in xcode:

embedded dylibs/frameworks only run on iOS 8 or later

Can this warning be ignored?
Will the app be rejected?

Framework not showing in finder

i am not able to import the framework in my project .. i tried method 2 .. show in finder doesnt show anything :( plz help btw i rele love it <3

USE UISearchBar

Hi I try to add UISearchBar but after pull to refresh update or select row the UISearchBar will missing , it's any solution for use UISearchBar ?

I did self.automaticallyAdjustsScrollViewInsets = true and false ,,, same result

Recursive loading

I managed to integrate this control to collection view. But somehow due to my special configuration, the refresher keep loading. Meaning, action block keep called.

I managed to fix that by changing PullToRefreshView.swift. I believe on line 132:

                    if (previousOffset < -(self.scrollViewInsetsDefaultValue.top + self.frame.size.height)) {
                        if (scrollView?.dragging == false && loading == false) {
                            loading = true
                        } else if (loading == true) {
                            labelTitle.text = "Loading ..."
                        } else {
                            labelTitle.text = "Release to refresh"
                            animator.changeProgress(-previousOffset / self.frame.size.height)
                        }
                    }

by considering scrollView insets. Please advice if you have better solution.

Swift KVO crash after deinit

hello, in your demo project, the view controller would't be released(memery leak).After I added unowned self, the view controller has deinit, but demo will crash. It will append <= iOS11, it's look like system bug.

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.