• Stars
    star
    814
  • Rank 56,027 (Top 2 %)
  • Language
    Objective-C
  • License
    MIT License
  • Created over 9 years ago
  • Updated almost 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A simple to use very generic pull-to-refresh and infinite scrolling functionalities as a UIScrollView category.

Introduction

INSPullToRefresh was written by MichaΕ‚ Zaborowski for inspace.io

INSPullToRefresh

INSPullToRefresh is a simple to use very generic pull-to-refresh and infinite scrolling functionalities as a UIScrollView category.

There are a lot of of pull to refresh views. We've never found one we are happy with. We always end up customizing one, so we decided to write one that's highly generic. You can just write you view and it to the content of pull to refresh or infinite scroll container view.

We wrote couple samples that can be found in popular apps like Facebook, Vine, Twitter etc.

Known Issue

automaticallyAdjustsScrollViewInsets property on UIViewController which is by default to YES is breaking a lot of stuff, so it will be automatically turned off when adding pull to refresh and managed by library manually.

Usage

Objective-C

[self.tableView ins_addPullToRefreshWithHeight:60.0 handler:^(UIScrollView *scrollView) {
    int64_t delayInSeconds = 1;
    dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, delayInSeconds * NSEC_PER_SEC);
    dispatch_after(popTime, dispatch_get_main_queue(), ^(void){
        [scrollView ins_endPullToRefresh];

    });
}];

CGRect defaultFrame = CGRectMake(0, 0, 24, 24);

UIView <INSPullToRefreshBackgroundViewDelegate> *pullToRefresh = [[INSDefaultPullToRefresh alloc] initWithFrame:defaultFrame backImage:[UIImage imageNamed:@"circleLight"] frontImage:[UIImage imageNamed:@"circleDark"]];

self.tableView.ins_pullToRefreshBackgroundView.delegate = pullToRefresh;
[self.tableView.ins_pullToRefreshBackgroundView addSubview:pullToRefresh];

Swift

self.tableView.ins_addPullToRefreshWithHeight(60.0, handler: { scrollView in
    let delayInSeconds: Int64 = 1
    let popTime: dispatch_time_t = dispatch_time(DISPATCH_TIME_NOW, delayInSeconds * Int64(NSEC_PER_SEC));
    
    dispatch_after(popTime, dispatch_get_main_queue()) {
        scrollView.ins_endPullToRefresh()
    }
    
    let defaultFrame = CGRectMake(0, 0, 24, 24)
    let pullToRefresh = INSDefaultPullToRefresh(frame: defaultFrame, backImage: UIImage(named: "default_child"), frontImage: UIImage(named: "default_user"))
    
    self.tableView.ins_pullToRefreshBackgroundView.delegate = pullToRefresh
    self.tableView.ins_pullToRefreshBackgroundView.addSubview(pullToRefresh)
})

All you need to do is handle two INSPullToRefreshBackgroundViewDelegate methods in your custom view.

@protocol INSPullToRefreshBackgroundViewDelegate <NSObject>
@optional
- (void)pullToRefreshBackgroundView:(INSPullToRefreshBackgroundView *)pullToRefreshBackgroundView didChangeState:(INSPullToRefreshBackgroundViewState)state;

- (void)pullToRefreshBackgroundView:(INSPullToRefreshBackgroundView *)pullToRefreshBackgroundView didChangeTriggerStateProgress:(CGFloat)progress;

@end

CocoaPods

Add the following to your Podfile and run $ pod install.

pod 'INSPullToRefresh'

If you don't have CocoaPods installed, you can learn how to do so here.

ARC

INSElectronicProgramGuideLayout uses ARC.

Contact

inspace.io

Twitter

License

The MIT License (MIT)

Copyright (c) 2015 inspace.io

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

More Repositories

1

MZFormSheetController

MZFormSheetController provides an alternative to the native iOS UIModalPresentationFormSheet, adding support for iPhone and additional opportunities to setup controller size and feel form sheet.
Objective-C
2,534
star
2

MZFormSheetPresentationController

MZFormSheetPresentationController provides an alternative to the native iOS UIModalPresentationFormSheet, adding support for iPhone and additional opportunities to setup UIPresentationController size and feel form sheet.
Objective-C
974
star
3

MZDayPicker

An iOS day picker to allow users to select date
Objective-C
620
star
4

WCAlertView

WCAlertView is deliverd from UIAlertView. It's support customization and blocks.
Objective-C
617
star
5

INSElectronicProgramGuideLayout

UICollectionViewLayout for displaying electronic program guide.
Objective-C
487
star
6

INSPhotoGallery

INSPhotoGallery is a modern looking photo gallery written in Swift for iOS.
Swift
396
star
7

MZBookshelfCollectionViewLayout

Bookshelf like iBooks layout for UICollectionView.
Objective-C
122
star
8

INSOperationsKit

Objective-C adaptation of the sample code provided in the Advanced NSOperations session of WWDC 2015
Objective-C
112
star
9

MZAppearance

UIAppearance proxy for custom objects
Objective-C
106
star
10

MZSelectableLabel

A simple to use drop in replacement for UILabel for iOS 7 that provides automatic detection of colors.
Objective-C
102
star
11

UIAlertController-MZStyle

Category for UIAlertController customization
Objective-C
94
star
12

MZFayeClient

Faye Client for iOS. Supports subscription blocks.
Objective-C
84
star
13

INSPersistentContainer

Open Source, 100% API compatible replacement of NSPersistentContainer for iOS8+
Objective-C
65
star
14

SpotifyImporter

Spotify library importer into Apple Music
Objective-C
55
star
15

WCBeforeAfter

Objective-C BeforeAfter
Objective-C
52
star
16

INSNibLoading

A UIView/NSView category and a subclass for loading custom view from UINib (xib) files
Objective-C
26
star
17

AccessibilityIdentificable

Identifiers for UI testing: a reflection based approach
Swift
22
star
18

source-tree-custom-commands

A collection of SourceTree CustomActions.
Shell
20
star
19

RWMAmazonProductAdvertisingManager

AFNetworking Client for Amazon Product Advertising API
Objective-C
13
star
20

ContextWatcher

Example which shows how to observe changes on single NSManagedObject instance
Swift
13
star
21

RWMVimeoClient

AFNetworking Client for Vimeo Advanced API
Objective-C
12
star
22

CCTouchableSprite

Touchable CCSprite for cocos2d framework with Objective-C Blocks
Objective-C
7
star
23

xcode-themes

My Xcode themes
1
star