Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

More documentation

  • Loading branch information...
commit 4be2e80030c6b4b2c57911cf5e9b97a1d96128e4 1 parent dfd1dc2
Sam Soffes soffes authored

Showing 2 changed files with 87 additions and 6 deletions. Show diff stats Hide diff stats

  1. +5 0 SSPullToRefresh.h
  2. +82 6 SSPullToRefreshView.h
5 SSPullToRefresh.h
@@ -6,6 +6,11 @@
6 6 // Copyright (c) 2012 Sam Soffes. All rights reserved.
7 7 //
8 8
  9 +// Main pull to refresh view. This class contains all of the pulling logic.
9 10 #import "SSPullToRefreshView.h"
  11 +
  12 +// Default content view. Similar to Facebook.
10 13 #import "SSPullToRefreshDefaultContentView.h"
  14 +
  15 +// Simple content view. Similar to Path.
11 16 #import "SSPullToRefreshSimpleContentView.h"
88 SSPullToRefreshView.h
@@ -47,11 +47,11 @@ typedef enum {
47 47
48 48 @interface SSPullToRefreshView : UIView
49 49
50   -@property (nonatomic, assign, readonly) UIScrollView *scrollView;
51   -@property (nonatomic, assign) id<SSPullToRefreshViewDelegate> delegate;
52   -@property (nonatomic, assign, readonly) SSPullToRefreshViewState state;
53   -@property (nonatomic, assign) CGFloat expandedHeight;
54   -@property (nonatomic, assign, readonly, getter = isExpanded) BOOL expanded;
  50 +/**
  51 + The content view displayed when the `scrollView` is pulled down. By default this is an instance of `SSPullToRefreshDefaultContentView`.
  52 +
  53 + @see SSPullToRefreshContentView
  54 + */
55 55 @property (nonatomic, strong) UIView<SSPullToRefreshContentView> *contentView;
56 56
57 57 /**
@@ -62,8 +62,53 @@ typedef enum {
62 62 @property (nonatomic, assign) UIEdgeInsets defaultContentInset;
63 63
64 64 /**
  65 + The height of the fully expanded content view. The default is `70.0`.
  66 +
  67 + The `contentView`'s `sizeThatFits:` will be respected when displayed but does not effect the expanded height. You can use this
  68 + to draw outside of the expanded area. If you don't implement `sizeThatFits:` it will automatically display at the default size.
  69 +
  70 + @see expanded
  71 + */
  72 +@property (nonatomic, assign) CGFloat expandedHeight;
  73 +
  74 +/**
  75 + A boolean indicating if the pull to refresh view is expanded.
  76 +
  77 + @see expandedHeight
  78 + @see startLoadingAndExpand:
  79 + */
  80 +@property (nonatomic, assign, readonly, getter = isExpanded) BOOL expanded;
  81 +
  82 +/**
  83 + The scroll view containing the pull to refresh view. This is automatically set with `initWithScrollView:delegate:`.
  84 +
  85 + @see initWithScrollView:delegate:
  86 + */
  87 +@property (nonatomic, assign, readonly) UIScrollView *scrollView;
  88 +
  89 +/**
  90 + The delegate is sent messages when the pull to refresh view starts loading. This is automatically set with `initWithScrollView:delegate:`.
  91 +
  92 + @see initWithScrollView:delegate:
  93 + @see SSPullToRefreshViewDelegate
  94 + */
  95 +@property (nonatomic, assign) id<SSPullToRefreshViewDelegate> delegate;
  96 +
  97 +/**
  98 + The state of the pull to refresh view.
  99 +
  100 + @see startLoading
  101 + @see startLoadingAndExpand:
  102 + @see finishLoading
  103 + @see SSPullToRefreshViewState
  104 + */
  105 +@property (nonatomic, assign, readonly) SSPullToRefreshViewState state;
  106 +
  107 +/**
65 108 All you need to do to add this view to your scroll view is call this method (passing in the scroll view). That's it.
66 109 You don't have to add it as subview or anything else. The rest is magic.
  110 +
  111 + You should only initalize with this method and never move it to another scroll view during its lifetime.
67 112 */
68 113 - (id)initWithScrollView:(UIScrollView *)scrollView delegate:(id<SSPullToRefreshViewDelegate>)delegate;
69 114
@@ -86,6 +131,9 @@ typedef enum {
86 131 */
87 132 - (void)finishLoading;
88 133
  134 +/**
  135 + Manually update the last updated at time. This will automatically get called when the pull to refresh view finishes laoding.
  136 + */
89 137 - (void)refreshLastUpdatedAt;
90 138
91 139 @end
@@ -95,9 +143,25 @@ typedef enum {
95 143
96 144 @optional
97 145
  146 +/**
  147 + Return `NO` if the pull to refresh view should no start loading.
  148 + */
98 149 - (BOOL)pullToRefreshViewShouldStartLoading:(SSPullToRefreshView *)view;
  150 +
  151 +/**
  152 + The pull to refresh view started loading. You should kick off whatever you need to load when this is called.
  153 + */
99 154 - (void)pullToRefreshViewDidStartLoading:(SSPullToRefreshView *)view;
  155 +
  156 +/**
  157 + The pull to refresh view finished loading. This will get called when it receives `finishLoading`.
  158 + */
100 159 - (void)pullToRefreshViewDidFinishLoading:(SSPullToRefreshView *)view;
  160 +
  161 +/**
  162 + The date when data was last updated. This will get called when it finishes loading or if it receives `refreshLastUpdatedAt`.
  163 + Some content views may display this date.
  164 + */
101 165 - (NSDate *)pullToRefreshViewLastUpdatedAt:(SSPullToRefreshView *)view;
102 166
103 167 @end
@@ -107,12 +171,24 @@ typedef enum {
107 171
108 172 @required
109 173
  174 +/**
  175 + The pull to refresh view's state has changed. The content view must update itself. All content view's must implement
  176 + this method.
  177 + */
110 178 - (void)setState:(SSPullToRefreshViewState)state withPullToRefreshView:(SSPullToRefreshView *)view;
111 179
112 180 @optional
113 181
114   -- (CGSize)contentSize;
  182 +/**
  183 + The pull to refresh view will set send values from `0.0` to `1.0` as the user pulls down. `1.0` means it is fully expanded and
  184 + will change to the `SSPullToRefreshViewStateReady` state. You can use this value to draw the progress of the pull
  185 + (i.e. Tweetbot style).
  186 + */
115 187 - (void)setPullProgress:(CGFloat)pullProgress;
  188 +
  189 +/**
  190 + The pull to refresh view updated its last updated date.
  191 + */
116 192 - (void)setLastUpdatedAt:(NSDate *)date withPullToRefreshView:(SSPullToRefreshView *)view;
117 193
118 194 @end

0 comments on commit 4be2e80

Please sign in to comment.
Something went wrong with that request. Please try again.