master
  1__*Upgrading from an earlier version?*: On October 25th, a complete and overdue refactor of this class was pushed that fixes memory issues as well as adds new feature people have been asking for a long time. I tried my best to make this a seamless transition (you will get some deprecation warnings).__
  2
  3__*Important note if your project doesn't use ARC*: you must add the @-fobjc-arc@ compiler flag to @UIScrollView+SVPullToRefresh.m@ and @UIScrollView+SVInfiniteScrolling.m@ in Target Settings > Build Phases > Compile Sources.__
  4
  5h1. SVPullToRefresh + SVInfiniteScrolling
  6
  7These 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 depending on delegates and/or subclassing @UIViewController@, SVPullToRefresh uses the Objective-C runtime to add the following 2 methods:
  8
  9<pre>
 10- (void)addPullToRefreshWithActionHandler:(void (^)(void))actionHandler;
 11- (void)addInfiniteScrollingWithActionHandler:(void (^)(void))actionHandler;
 12</pre>
 13
 14h2. Installation
 15
 16* Drag the @SVPullToRefresh/SVPullToRefresh@ folder into your project. 
 17* Add the *QuartzCore* framework to your project.
 18* Import @UIScrollView+SVPullToRefresh.h@ and/or @UIScrollView+SVInfiniteScrolling.m@
 19
 20h2. Usage
 21
 22(see sample Xcode project in @/Demo@)
 23
 24h3. Adding Pull to Refresh
 25
 26<pre>
 27[tableView addPullToRefreshWithActionHandler:^{
 28    // prepend data to dataSource, insert cells at top of table view
 29    // call [tableView.pullToRefreshView stopAnimating] when done
 30}];
 31</pre>
 32
 33If you’d like to programmatically trigger the refresh (for instance in viewDidLoad), you can do so with:
 34
 35<pre>
 36[tableView triggerPullToRefresh];
 37</pre>
 38
 39You can temporarily hide the pull to refresh view by setting the @showsPullToRefresh@ property:
 40
 41<pre>
 42tableView.showsPullToRefresh = NO;
 43</pre>
 44
 45h4. Customization
 46
 47The pull to refresh view can be customized using the following properties/methods:
 48
 49<pre>
 50@property (nonatomic, strong) UIColor *arrowColor;
 51@property (nonatomic, strong) UIColor *textColor;
 52@property (nonatomic, readwrite) UIActivityIndicatorViewStyle activityIndicatorViewStyle;
 53
 54- (void)setTitle:(NSString *)title forState:(SVPullToRefreshState)state;
 55- (void)setSubtitle:(NSString *)subtitle forState:(SVPullToRefreshState)state;
 56- (void)setCustomView:(UIView *)view forState:(SVPullToRefreshState)state;
 57</pre>
 58
 59You can access these properties through your scroll view's @pullToRefreshView@ property. 
 60
 61For instance, you would set the @arrowColor@ property using:
 62
 63<pre>
 64tableView.pullToRefreshView.arrowColor = [UIColor whiteColor];
 65</pre>
 66
 67
 68h3. Adding Infinite Scrolling
 69
 70<pre>
 71[tableView addInfiniteScrollingWithActionHandler:^{
 72    // append data to data source, insert new cells at the end of table view
 73}];
 74</pre>
 75
 76If you’d like to programmatically trigger the refresh (for instance in viewDidLoad), you can do so with:
 77
 78<pre>
 79[tableView triggerInfiniteScrolling];
 80</pre>
 81
 82You can temporarily hide the infinite scrolling view by setting the @showsInfiniteScrolling@ property:
 83
 84<pre>
 85tableView.showsInfiniteScrolling = NO;
 86</pre>
 87
 88If you'd like to keep the infinite scrolling view around but disable the action handler and state changing:
 89
 90<pre>
 91tableView.infiniteScrollingView.enabled = NO;
 92</pre>
 93
 94When disabled, the `state` property will always return `SVInfiniteScrollingStateStopped`.
 95
 96h4. Customization
 97
 98The infinite scrolling view can be customized using the following properties/methods:
 99
100<pre>
101@property (nonatomic, readwrite) UIActivityIndicatorViewStyle activityIndicatorViewStyle;
102
103- (void)setCustomView:(UIView *)view forState:(SVInfiniteScrollingState)state;
104</pre>
105
106You can access these properties through your scroll view's @infiniteScrollingView@ property. 
107
108h2. Under the hood
109
110SVPullToRefresh extends @UIScrollView@ by adding new public methods as well as a dynamic properties (thanks "@seb_morel":http://twitter.com/seb_morel!). It uses key-value observing to track the scrollView's @contentOffset@, which removes the need for the view to be linked to the @UIScrollViewDelegate@ protocol.
111
112h2. Credits
113
114SVPullToRefresh is brought to you by "Sam Vermette":http://samvermette.com and "contributors to the project":https://github.com/samvermette/SVPullToRefresh/contributors. If you have feature suggestions or bug reports, feel free to help out by sending pull requests or by "creating new issues":https://github.com/samvermette/SVPullToRefresh/issues/new. If you're using SVPullToRefresh in your project, attribution would be nice. 
115
116Big 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 permitted the level of abstraction found in SVPullToRefresh.
117
118Hat tip to "Loren Brichter":http://twitter.com/lorenb for inventing such a great UI mechanism.