Skip to content

Commit 076578e

Browse files
committed
Added option for pull to refresh from bottom
1 parent fb40dd6 commit 076578e

File tree

3 files changed

+196
-47
lines changed

3 files changed

+196
-47
lines changed

README.md

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
# SVPullToRefresh + SVInfiniteScrolling
22

3-
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`:
3+
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`:
44

55
```objective-c
66
- (void)addPullToRefreshWithActionHandler:(void (^)(void))actionHandler;
7+
- (void)addPullToRefreshWithActionHandler:(void (^)(void))actionHandler position:(SVPullToRefreshPosition)position;
78
- (void)addInfiniteScrollingWithActionHandler:(void (^)(void))actionHandler;
89
```
910

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

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

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

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

115-
Hat tip to [Loren Brichter](http://twitter.com/lorenb) for inventing pull-to-refresh.
124+
Hat tip to [Loren Brichter](http://twitter.com/lorenb) for inventing pull-to-refresh.

SVPullToRefresh/UIScrollView+SVPullToRefresh.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,15 @@
1515

1616
@interface UIScrollView (SVPullToRefresh)
1717

18+
enum {
19+
SVPullToRefreshPositionTop = 0,
20+
SVPullToRefreshPositionBottom,
21+
};
22+
23+
typedef NSUInteger SVPullToRefreshPosition;
24+
1825
- (void)addPullToRefreshWithActionHandler:(void (^)(void))actionHandler;
26+
- (void)addPullToRefreshWithActionHandler:(void (^)(void))actionHandler position:(SVPullToRefreshPosition)position;
1927
- (void)triggerPullToRefresh;
2028

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

4452
@property (nonatomic, readonly) SVPullToRefreshState state;
53+
@property (nonatomic, readonly) SVPullToRefreshPosition position;
4554

4655
- (void)setTitle:(NSString *)title forState:(SVPullToRefreshState)state;
4756
- (void)setSubtitle:(NSString *)subtitle forState:(SVPullToRefreshState)state;

0 commit comments

Comments
 (0)