Skip to content

Commit

Permalink
Added option for pull to refresh from bottom
Browse files Browse the repository at this point in the history
  • Loading branch information
gabro committed Apr 27, 2013
1 parent fb40dd6 commit 076578e
Show file tree
Hide file tree
Showing 3 changed files with 196 additions and 47 deletions.
13 changes: 11 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
# SVPullToRefresh + SVInfiniteScrolling

These UIScrollView categories makes it super easy to add pull-to-refresh and infinite scrolling fonctionalities to any UIScrollView (or any of its subclass). Instead of relying on delegates and/or subclassing `UIViewController`, SVPullToRefresh uses the Objective-C runtime to add the following 2 methods to `UIScrollView`:
These UIScrollView categories makes it super easy to add pull-to-refresh and infinite scrolling fonctionalities to any UIScrollView (or any of its subclass). Instead of relying on delegates and/or subclassing `UIViewController`, SVPullToRefresh uses the Objective-C runtime to add the following 3 methods to `UIScrollView`:

```objective-c
- (void)addPullToRefreshWithActionHandler:(void (^)(void))actionHandler;
- (void)addPullToRefreshWithActionHandler:(void (^)(void))actionHandler position:(SVPullToRefreshPosition)position;
- (void)addInfiniteScrollingWithActionHandler:(void (^)(void))actionHandler;
```

Expand Down Expand Up @@ -33,6 +34,14 @@ _**Important note if your project doesn't use ARC**: you must add the `-fobjc-ar
// call [tableView.pullToRefreshView stopAnimating] when done
}];
```
or if you want pull to refresh from the bottom
```objective-c
[tableView addPullToRefreshWithActionHandler:^{
// prepend data to dataSource, insert cells at top of table view
// call [tableView.pullToRefreshView stopAnimating] when done
} position:SVPullToRefreshPositionBottom];
```

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

Expand Down Expand Up @@ -112,4 +121,4 @@ SVPullToRefresh is brought to you by [Sam Vermette](http:https://samvermette.com) and

Big thanks to [@seb_morel](http:https://twitter.com/seb_morel) for his [Demistifying the Objective-C runtime](http:https://cocoaheadsmtl.s3.amazonaws.com/demistifying-runtime.pdf) talk which really helped for this project.

Hat tip to [Loren Brichter](http:https://twitter.com/lorenb) for inventing pull-to-refresh.
Hat tip to [Loren Brichter](http:https://twitter.com/lorenb) for inventing pull-to-refresh.
9 changes: 9 additions & 0 deletions SVPullToRefresh/UIScrollView+SVPullToRefresh.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,15 @@

@interface UIScrollView (SVPullToRefresh)

enum {
SVPullToRefreshPositionTop = 0,
SVPullToRefreshPositionBottom,
};

typedef NSUInteger SVPullToRefreshPosition;

- (void)addPullToRefreshWithActionHandler:(void (^)(void))actionHandler;
- (void)addPullToRefreshWithActionHandler:(void (^)(void))actionHandler position:(SVPullToRefreshPosition)position;
- (void)triggerPullToRefresh;

@property (nonatomic, strong, readonly) SVPullToRefreshView *pullToRefreshView;
Expand All @@ -42,6 +50,7 @@ typedef NSUInteger SVPullToRefreshState;
@property (nonatomic, readwrite) UIActivityIndicatorViewStyle activityIndicatorViewStyle;

@property (nonatomic, readonly) SVPullToRefreshState state;
@property (nonatomic, readonly) SVPullToRefreshPosition position;

- (void)setTitle:(NSString *)title forState:(SVPullToRefreshState)state;
- (void)setSubtitle:(NSString *)subtitle forState:(SVPullToRefreshState)state;
Expand Down
Loading

0 comments on commit 076578e

Please sign in to comment.