Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added state tracking/setting

  • Loading branch information...
commit 9b825d31a0ff2713af2282d28a5c0551cb6f863c 1 parent 17e8147
@devindoty devindoty authored
View
20 Demo/TableViewPull/Classes/Controller/RootViewController/RootViewController.m
@@ -27,11 +27,6 @@
#import "RootViewController.h"
#import "EGORefreshTableHeaderView.h"
-#define kReleaseToReloadStatus 0
-#define kPullToReloadStatus 1
-#define kLoadingStatus 2
-
-
@interface RootViewController (Private)
- (void)dataSourceDidFinishLoadingNewData;
@@ -194,12 +189,10 @@ - (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)
- (void)scrollViewDidScroll:(UIScrollView *)scrollView{
if (scrollView.isDragging) {
- if (refreshHeaderView.isFlipped && scrollView.contentOffset.y > -65.0f && scrollView.contentOffset.y < 0.0f && !_reloading) {
- [refreshHeaderView flipImageAnimated:YES];
- [refreshHeaderView setStatus:kPullToReloadStatus];
- } else if (!refreshHeaderView.isFlipped && scrollView.contentOffset.y < -65.0f && !_reloading) {
- [refreshHeaderView flipImageAnimated:YES];
- [refreshHeaderView setStatus:kReleaseToReloadStatus];
+ if (refreshHeaderView.state == EGOOPullRefreshPulling && scrollView.contentOffset.y > -65.0f && scrollView.contentOffset.y < 0.0f && !_reloading) {
+ [refreshHeaderView setState:EGOOPullRefreshNormal];
+ } else if (refreshHeaderView.state == EGOOPullRefreshNormal && scrollView.contentOffset.y < -65.0f && !_reloading) {
+ [refreshHeaderView setState:EGOOPullRefreshPulling];
}
}
}
@@ -209,7 +202,7 @@ - (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL
if (scrollView.contentOffset.y <= - 65.0f && !_reloading) {
_reloading = YES;
[self reloadTableViewDataSource];
- [refreshHeaderView toggleActivityView];
+ [refreshHeaderView setState:EGOOPullRefreshLoading];
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.2];
self.tableView.contentInset = UIEdgeInsetsMake(60.0f, 0.0f, 0.0f, 0.0f);
@@ -226,8 +219,7 @@ - (void)dataSourceDidFinishLoadingNewData{
[self.tableView setContentInset:UIEdgeInsetsMake(0.0f, 0.0f, 0.0f, 0.0f)];
[UIView commitAnimations];
- [refreshHeaderView flipImageAnimated:NO]; // reset view
- [refreshHeaderView toggleActivityView]; // reset view
+ [refreshHeaderView setState:EGOOPullRefreshNormal];
[refreshHeaderView setCurrentDate]; // should check if data reload was successful
}
View
15 Demo/TableViewPull/Classes/View/RefreshTableHeaderView/EGORefreshTableHeaderView.h
@@ -27,6 +27,13 @@
#import <UIKit/UIKit.h>
#import <QuartzCore/QuartzCore.h>
+
+typedef enum{
+ EGOOPullRefreshPulling = 0,
+ EGOOPullRefreshNormal,
+ EGOOPullRefreshLoading,
+} EGOPullRefreshState;
+
@interface EGORefreshTableHeaderView : UIView {
UILabel *lastUpdatedLabel;
@@ -34,15 +41,13 @@
CALayer *arrowImage;
UIActivityIndicatorView *activityView;
- BOOL isFlipped;
+ EGOPullRefreshState _state;
}
-@property BOOL isFlipped;
+@property(nonatomic,assign) EGOPullRefreshState state;
-- (void)flipImageAnimated:(BOOL)animated;
- (void)setCurrentDate;
-- (void)toggleActivityView;
-- (void)setStatus:(int)status;
+- (void)setState:(EGOPullRefreshState)aState;
@end
View
85 Demo/TableViewPull/Classes/View/RefreshTableHeaderView/EGORefreshTableHeaderView.m
@@ -26,9 +26,6 @@
#import "EGORefreshTableHeaderView.h"
-#define kReleaseToReloadStatus 0
-#define kPullToReloadStatus 1
-#define kLoadingStatus 2
#define TEXT_COLOR [UIColor colorWithRed:87.0/255.0 green:108.0/255.0 blue:137.0/255.0 alpha:1.0]
#define BORDER_COLOR [UIColor colorWithRed:87.0/255.0 green:108.0/255.0 blue:137.0/255.0 alpha:1.0]
@@ -36,7 +33,7 @@
@implementation EGORefreshTableHeaderView
-@synthesize isFlipped;
+@synthesize state=_state;
- (id)initWithFrame:(CGRect)frame {
@@ -69,7 +66,7 @@ - (id)initWithFrame:(CGRect)frame {
statusLabel.shadowOffset = CGSizeMake(0.0f, 1.0f);
statusLabel.backgroundColor = [UIColor clearColor];
statusLabel.textAlignment = UITextAlignmentCenter;
- [self setStatus:kPullToReloadStatus];
+ [self setState:EGOOPullRefreshNormal];
[self addSubview:statusLabel];
[statusLabel release];
@@ -86,7 +83,6 @@ - (id)initWithFrame:(CGRect)frame {
[self addSubview:activityView];
[activityView release];
- isFlipped = NO;
}
return self;
}
@@ -101,26 +97,6 @@ - (void)drawRect:(CGRect)rect{
CGContextStrokePath(context);
}
-- (void)flipImageAnimated:(BOOL)animated{
-
- if (!animated) {
- [CATransaction begin];
- [CATransaction setValue:(id)kCFBooleanTrue forKey:kCATransactionDisableActions];
- arrowImage.transform = CATransform3DIdentity;
- [CATransaction commit];
- } else {
- [CATransaction begin];
- [CATransaction setAnimationDuration:animated ? .18 : 0.0];
-
- CATransform3D transform = isFlipped ? CATransform3DIdentity : CATransform3DMakeRotation((M_PI / 180.0) * 180.0f, 0.0f, 0.0f, 1.0f);
- arrowImage.transform = transform;
-
- [CATransaction commit];
- }
-
- isFlipped = !isFlipped;
-}
-
- (void)setCurrentDate {
NSDateFormatter* formatter = [[NSDateFormatter alloc] init];
[formatter setAMSymbol:@"AM"];
@@ -132,38 +108,51 @@ - (void)setCurrentDate {
[formatter release];
}
-- (void)setStatus:(int)status{
- switch (status) {
- case kReleaseToReloadStatus:
+- (void)setState:(EGOPullRefreshState)aState{
+
+ switch (aState) {
+ case EGOOPullRefreshPulling:
+
statusLabel.text = @"Release to refresh...";
+ [CATransaction begin];
+ [CATransaction setAnimationDuration:.18];
+ arrowImage.transform = CATransform3DMakeRotation((M_PI / 180.0) * 180.0f, 0.0f, 0.0f, 1.0f);
+ [CATransaction commit];
+
break;
- case kPullToReloadStatus:
+ case EGOOPullRefreshNormal:
+
+ if (_state == EGOOPullRefreshPulling) {
+ [CATransaction begin];
+ [CATransaction setAnimationDuration:.18];
+ arrowImage.transform = CATransform3DIdentity;
+ [CATransaction commit];
+ }
+
statusLabel.text = @"Pull down to refresh...";
+ [activityView stopAnimating];
+ [CATransaction begin];
+ [CATransaction setValue:(id)kCFBooleanTrue forKey:kCATransactionDisableActions];
+ arrowImage.hidden = NO;
+ arrowImage.transform = CATransform3DIdentity;
+ [CATransaction commit];
+
break;
- case kLoadingStatus:
+ case EGOOPullRefreshLoading:
+
statusLabel.text = @"Loading...";
+ [activityView startAnimating];
+ [CATransaction begin];
+ [CATransaction setValue:(id)kCFBooleanTrue forKey:kCATransactionDisableActions];
+ arrowImage.hidden = YES;
+ [CATransaction commit];
+
break;
default:
break;
}
-}
-
-- (void)toggleActivityView{
-
- [CATransaction begin];
- [CATransaction setValue:(id)kCFBooleanTrue forKey:kCATransactionDisableActions]; // kill layers implicit fade animation
-
- if ([activityView isAnimating]) {
- [activityView stopAnimating];
- arrowImage.hidden = NO;
- [self setStatus:kPullToReloadStatus];
- } else {
- [activityView startAnimating];
- arrowImage.hidden = YES;
- [self setStatus:kLoadingStatus];
- }
- [CATransaction commit];
+ _state = aState;
}
- (void)dealloc {
View
225 Demo/TableViewPull/TableViewPull.xcodeproj/codekeeper.mode1v3
@@ -216,126 +216,7 @@
</dict>
</array>
<key>OpenEditors</key>
- <array>
- <dict>
- <key>Content</key>
- <dict>
- <key>PBXProjectModuleGUID</key>
- <string>3A451E5410D1755B00C10A50</string>
- <key>PBXProjectModuleLabel</key>
- <string>EGORefreshTableHeaderView.m</string>
- <key>PBXSplitModuleInNavigatorKey</key>
- <dict>
- <key>Split0</key>
- <dict>
- <key>PBXProjectModuleGUID</key>
- <string>3A451E5510D1755B00C10A50</string>
- <key>PBXProjectModuleLabel</key>
- <string>EGORefreshTableHeaderView.m</string>
- <key>history</key>
- <array>
- <string>3A451E9C10D176CB00C10A50</string>
- <string>3ABDA77C10D1862E003ABED5</string>
- </array>
- </dict>
- <key>SplitCount</key>
- <string>1</string>
- </dict>
- <key>StatusBarVisibility</key>
- <true/>
- </dict>
- <key>Geometry</key>
- <dict>
- <key>Frame</key>
- <string>{{0, 20}, {1310, 836}}</string>
- <key>PBXModuleWindowStatusBarHidden2</key>
- <false/>
- <key>RubberWindowFrame</key>
- <string>2663 12 1310 877 1680 -99 1680 1050 </string>
- </dict>
- </dict>
- <dict>
- <key>Content</key>
- <dict>
- <key>PBXProjectModuleGUID</key>
- <string>3A3D90FC11188487002B6585</string>
- <key>PBXProjectModuleLabel</key>
- <string>RootViewController.m</string>
- <key>PBXSplitModuleInNavigatorKey</key>
- <dict>
- <key>Split0</key>
- <dict>
- <key>PBXProjectModuleGUID</key>
- <string>3A3D90FD11188487002B6585</string>
- <key>PBXProjectModuleLabel</key>
- <string>RootViewController.m</string>
- <key>_historyCapacity</key>
- <integer>0</integer>
- <key>bookmark</key>
- <string>3A3D914C11188665002B6585</string>
- <key>history</key>
- <array>
- <string>3A3D90FE11188487002B6585</string>
- <string>3A3D90FF11188487002B6585</string>
- </array>
- </dict>
- <key>SplitCount</key>
- <string>1</string>
- </dict>
- <key>StatusBarVisibility</key>
- <true/>
- </dict>
- <key>Geometry</key>
- <dict>
- <key>Frame</key>
- <string>{{0, 20}, {1294, 826}}</string>
- <key>PBXModuleWindowStatusBarHidden2</key>
- <false/>
- <key>RubberWindowFrame</key>
- <string>15 156 1294 867 0 0 1680 1028 </string>
- </dict>
- </dict>
- <dict>
- <key>Content</key>
- <dict>
- <key>PBXProjectModuleGUID</key>
- <string>3A3D90951118802C002B6585</string>
- <key>PBXProjectModuleLabel</key>
- <string>TableViewPullAppDelegate.m</string>
- <key>PBXSplitModuleInNavigatorKey</key>
- <dict>
- <key>Split0</key>
- <dict>
- <key>PBXProjectModuleGUID</key>
- <string>3A3D90961118802C002B6585</string>
- <key>PBXProjectModuleLabel</key>
- <string>TableViewPullAppDelegate.m</string>
- <key>_historyCapacity</key>
- <integer>0</integer>
- <key>bookmark</key>
- <string>3A3D914D11188665002B6585</string>
- <key>history</key>
- <array>
- <string>3A3D908F11187FEC002B6585</string>
- </array>
- </dict>
- <key>SplitCount</key>
- <string>1</string>
- </dict>
- <key>StatusBarVisibility</key>
- <true/>
- </dict>
- <key>Geometry</key>
- <dict>
- <key>Frame</key>
- <string>{{0, 20}, {1294, 826}}</string>
- <key>PBXModuleWindowStatusBarHidden2</key>
- <false/>
- <key>RubberWindowFrame</key>
- <string>15 156 1294 867 0 0 1680 1028 </string>
- </dict>
- </dict>
- </array>
+ <array/>
<key>PerspectiveWidths</key>
<array>
<integer>-1</integer>
@@ -466,20 +347,18 @@
<key>_historyCapacity</key>
<integer>0</integer>
<key>bookmark</key>
- <string>3A3D914B11188665002B6585</string>
+ <string>3A3D946E11189C73002B6585</string>
<key>history</key>
<array>
<string>3A451E9110D176B300C10A50</string>
<string>3ABDA76A10D18625003ABED5</string>
- <string>3ABDA76D10D18625003ABED5</string>
- <string>3ABDA76E10D18625003ABED5</string>
<string>3A3D90BC11188277002B6585</string>
<string>3A3D90D3111882D9002B6585</string>
<string>3A3D90D4111882D9002B6585</string>
<string>3A3D90D5111882D9002B6585</string>
- <string>3A3D91091118849B002B6585</string>
<string>3A3D912911188570002B6585</string>
- <string>3A3D912211188548002B6585</string>
+ <string>3A3D946D11189C73002B6585</string>
+ <string>3A3D943311189ADA002B6585</string>
</array>
</dict>
<key>SplitCount</key>
@@ -491,14 +370,14 @@
<key>GeometryConfiguration</key>
<dict>
<key>Frame</key>
- <string>{{0, 0}, {930, 542}}</string>
+ <string>{{0, 0}, {930, 536}}</string>
<key>RubberWindowFrame</key>
<string>1852 126 1283 793 1680 -99 1680 1050 </string>
</dict>
<key>Module</key>
<string>PBXNavigatorGroup</string>
<key>Proportion</key>
- <string>542pt</string>
+ <string>536pt</string>
</dict>
<dict>
<key>ContentConfiguration</key>
@@ -511,14 +390,14 @@
<key>GeometryConfiguration</key>
<dict>
<key>Frame</key>
- <string>{{0, 547}, {930, 205}}</string>
+ <string>{{0, 541}, {930, 211}}</string>
<key>RubberWindowFrame</key>
<string>1852 126 1283 793 1680 -99 1680 1050 </string>
</dict>
<key>Module</key>
<string>XCDetailModule</string>
<key>Proportion</key>
- <string>205pt</string>
+ <string>211pt</string>
</dict>
</array>
<key>Proportion</key>
@@ -537,9 +416,9 @@
</array>
<key>TableOfContents</key>
<array>
- <string>3A3D906A11187F15002B6585</string>
+ <string>3A3D93A01118970A002B6585</string>
<string>1CE0B1FE06471DED0097A5F4</string>
- <string>3A3D906B11187F15002B6585</string>
+ <string>3A3D93A11118970A002B6585</string>
<string>1CE0B20306471E060097A5F4</string>
<string>1CE0B20506471E060097A5F4</string>
</array>
@@ -660,7 +539,7 @@
<key>StatusbarIsVisible</key>
<true/>
<key>TimeStamp</key>
- <real>286819941.98460102</real>
+ <real>286825587.530909</real>
<key>ToolbarConfigUserDefaultsMinorVersion</key>
<string>2</string>
<key>ToolbarDisplayMode</key>
@@ -679,10 +558,8 @@
<array>
<string>1C78EAAD065D492600B07095</string>
<string>1CD10A99069EF8BA00B06720</string>
+ <string>1C530D57069F1CE1000CFCEE</string>
<string>3A2581631088BE7100126784</string>
- <string>3A3D90951118802C002B6585</string>
- <string>3A3D90FC11188487002B6585</string>
- <string>3A451E5410D1755B00C10A50</string>
<string>/Users/codekeeper/Documents/iPhone Dev/EGOTableViewPullRefresh/Demo/TableViewPull/TableViewPull.xcodeproj</string>
</array>
<key>WindowString</key>
@@ -702,12 +579,14 @@
<key>Dock</key>
<array>
<dict>
+ <key>BecomeActive</key>
+ <true/>
<key>ContentConfiguration</key>
<dict>
<key>PBXProjectModuleGUID</key>
<string>1CD0528F0623707200166675</string>
<key>PBXProjectModuleLabel</key>
- <string>EGORefreshTableHeaderView.m</string>
+ <string>RootViewController.m</string>
<key>StatusBarVisibility</key>
<true/>
</dict>
@@ -724,8 +603,6 @@
<string>218pt</string>
</dict>
<dict>
- <key>BecomeActive</key>
- <true/>
<key>ContentConfiguration</key>
<dict>
<key>PBXProjectModuleGUID</key>
@@ -765,7 +642,7 @@
<key>TableOfContents</key>
<array>
<string>3A2581631088BE7100126784</string>
- <string>3A3D906E11187F15002B6585</string>
+ <string>3A3D938C11189605002B6585</string>
<string>1CD0528F0623707200166675</string>
<string>XCMainBuildResultsModuleGUID</string>
</array>
@@ -809,8 +686,8 @@
<string>yes</string>
<key>sizes</key>
<array>
- <string>{{0, 0}, {316, 201}}</string>
- <string>{{316, 0}, {378, 201}}</string>
+ <string>{{0, 0}, {316, 202}}</string>
+ <string>{{316, 0}, {378, 202}}</string>
</array>
</dict>
<key>VerticalSplitView</key>
@@ -825,8 +702,8 @@
<string>yes</string>
<key>sizes</key>
<array>
- <string>{{0, 0}, {694, 201}}</string>
- <string>{{0, 201}, {694, 180}}</string>
+ <string>{{0, 0}, {694, 202}}</string>
+ <string>{{0, 202}, {694, 179}}</string>
</array>
</dict>
</dict>
@@ -859,7 +736,7 @@
<real>148</real>
</array>
<key>Frame</key>
- <string>{{316, 0}, {378, 201}}</string>
+ <string>{{316, 0}, {378, 202}}</string>
<key>RubberWindowFrame</key>
<string>886 411 694 422 0 0 1680 1028 </string>
</dict>
@@ -887,13 +764,13 @@
<key>TableOfContents</key>
<array>
<string>1CD10A99069EF8BA00B06720</string>
- <string>3A3D90B411188260002B6585</string>
+ <string>3A3D93A91118970A002B6585</string>
<string>1C162984064C10D400B95A72</string>
- <string>3A3D90B511188260002B6585</string>
- <string>3A3D90B611188260002B6585</string>
- <string>3A3D90B711188260002B6585</string>
- <string>3A3D90B811188260002B6585</string>
- <string>3A3D90B911188260002B6585</string>
+ <string>3A3D93AA1118970A002B6585</string>
+ <string>3A3D93AB1118970A002B6585</string>
+ <string>3A3D93AC1118970A002B6585</string>
+ <string>3A3D93AD1118970A002B6585</string>
+ <string>3A3D93AE1118970A002B6585</string>
</array>
<key>ToolbarConfiguration</key>
<string>xcode.toolbar.config.debugV3</string>
@@ -905,8 +782,12 @@
<false/>
</dict>
<dict>
+ <key>FirstTimeWindowDisplayed</key>
+ <false/>
<key>Identifier</key>
<string>windowTool.find</string>
+ <key>IsVertical</key>
+ <true/>
<key>Layout</key>
<array>
<dict>
@@ -921,26 +802,16 @@
<key>PBXProjectModuleGUID</key>
<string>1CDD528C0622207200134675</string>
<key>PBXProjectModuleLabel</key>
- <string>&lt;No Editor&gt;</string>
- <key>PBXSplitModuleInNavigatorKey</key>
- <dict>
- <key>Split0</key>
- <dict>
- <key>PBXProjectModuleGUID</key>
- <string>1CD0528D0623707200166675</string>
- </dict>
- <key>SplitCount</key>
- <string>1</string>
- </dict>
+ <string>RootViewController.m</string>
<key>StatusBarVisibility</key>
- <integer>1</integer>
+ <true/>
</dict>
<key>GeometryConfiguration</key>
<dict>
<key>Frame</key>
- <string>{{0, 0}, {781, 167}}</string>
+ <string>{{0, 0}, {781, 212}}</string>
<key>RubberWindowFrame</key>
- <string>62 385 781 470 0 0 1440 878 </string>
+ <string>549 435 781 470 0 0 1680 1028 </string>
</dict>
<key>Module</key>
<string>PBXNavigatorGroup</string>
@@ -949,11 +820,11 @@
</dict>
</array>
<key>Proportion</key>
- <string>50%</string>
+ <string>212pt</string>
</dict>
<dict>
<key>BecomeActive</key>
- <integer>1</integer>
+ <true/>
<key>ContentConfiguration</key>
<dict>
<key>PBXProjectModuleGUID</key>
@@ -964,18 +835,18 @@
<key>GeometryConfiguration</key>
<dict>
<key>Frame</key>
- <string>{{8, 0}, {773, 254}}</string>
+ <string>{{0, 217}, {781, 212}}</string>
<key>RubberWindowFrame</key>
- <string>62 385 781 470 0 0 1440 878 </string>
+ <string>549 435 781 470 0 0 1680 1028 </string>
</dict>
<key>Module</key>
<string>PBXProjectFindModule</string>
<key>Proportion</key>
- <string>50%</string>
+ <string>212pt</string>
</dict>
</array>
<key>Proportion</key>
- <string>428pt</string>
+ <string>429pt</string>
</dict>
</array>
<key>Name</key>
@@ -985,23 +856,21 @@
<string>PBXProjectFindModule</string>
</array>
<key>StatusbarIsVisible</key>
- <integer>1</integer>
+ <true/>
<key>TableOfContents</key>
<array>
<string>1C530D57069F1CE1000CFCEE</string>
- <string>1C530D58069F1CE1000CFCEE</string>
- <string>1C530D59069F1CE1000CFCEE</string>
+ <string>3A3D9397111896FA002B6585</string>
+ <string>3A3D9398111896FA002B6585</string>
<string>1CDD528C0622207200134675</string>
- <string>1C530D5A069F1CE1000CFCEE</string>
- <string>1CE0B1FE06471DED0097A5F4</string>
<string>1CD0528E0623707200166675</string>
</array>
<key>WindowString</key>
- <string>62 385 781 470 0 0 1440 878 </string>
+ <string>549 435 781 470 0 0 1680 1028 </string>
<key>WindowToolGUID</key>
<string>1C530D57069F1CE1000CFCEE</string>
<key>WindowToolIsVisible</key>
- <integer>0</integer>
+ <false/>
</dict>
<dict>
<key>Identifier</key>
@@ -1057,7 +926,7 @@
<key>TableOfContents</key>
<array>
<string>1C78EAAD065D492600B07095</string>
- <string>3A3D910E1118849B002B6585</string>
+ <string>3A3D93AF1118970A002B6585</string>
<string>1C78EAAC065D492600B07095</string>
</array>
<key>ToolbarConfiguration</key>
View
197 Demo/TableViewPull/TableViewPull.xcodeproj/codekeeper.pbxuser
@@ -99,29 +99,20 @@
PBXFileDataSource_Warnings_ColumnID,
);
};
- PBXPerProjectTemplateStateSaveDate = 286818053;
- PBXWorkspaceStateSaveDate = 286818053;
+ PBXPerProjectTemplateStateSaveDate = 286823800;
+ PBXWorkspaceStateSaveDate = 286823800;
};
perUserProjectItems = {
- 3A3D908F11187FEC002B6585 /* PBXBookmark */ = 3A3D908F11187FEC002B6585 /* PBXBookmark */;
3A3D90BC11188277002B6585 /* PBXTextBookmark */ = 3A3D90BC11188277002B6585 /* PBXTextBookmark */;
3A3D90D3111882D9002B6585 /* PBXTextBookmark */ = 3A3D90D3111882D9002B6585 /* PBXTextBookmark */;
3A3D90D4111882D9002B6585 /* PBXBookmark */ = 3A3D90D4111882D9002B6585 /* PBXBookmark */;
3A3D90D5111882D9002B6585 /* PBXTextBookmark */ = 3A3D90D5111882D9002B6585 /* PBXTextBookmark */;
- 3A3D90FE11188487002B6585 /* PBXTextBookmark */ = 3A3D90FE11188487002B6585 /* PBXTextBookmark */;
- 3A3D90FF11188487002B6585 /* PBXTextBookmark */ = 3A3D90FF11188487002B6585 /* PBXTextBookmark */;
- 3A3D91091118849B002B6585 /* PBXTextBookmark */ = 3A3D91091118849B002B6585 /* PBXTextBookmark */;
- 3A3D912211188548002B6585 /* XCBuildMessageTextBookmark */ = 3A3D912211188548002B6585 /* XCBuildMessageTextBookmark */;
3A3D912911188570002B6585 /* PBXTextBookmark */ = 3A3D912911188570002B6585 /* PBXTextBookmark */;
- 3A3D914B11188665002B6585 /* PBXTextBookmark */ = 3A3D914B11188665002B6585 /* PBXTextBookmark */;
- 3A3D914C11188665002B6585 /* PBXTextBookmark */ = 3A3D914C11188665002B6585 /* PBXTextBookmark */;
- 3A3D914D11188665002B6585 /* PBXTextBookmark */ = 3A3D914D11188665002B6585 /* PBXTextBookmark */;
+ 3A3D943311189ADA002B6585 /* PBXTextBookmark */ = 3A3D943311189ADA002B6585 /* PBXTextBookmark */;
+ 3A3D946D11189C73002B6585 /* PBXTextBookmark */ = 3A3D946D11189C73002B6585 /* PBXTextBookmark */;
+ 3A3D946E11189C73002B6585 /* PBXTextBookmark */ = 3A3D946E11189C73002B6585 /* PBXTextBookmark */;
3A451E9110D176B300C10A50 /* PBXBookmark */ = 3A451E9110D176B300C10A50 /* PBXBookmark */;
- 3A451E9C10D176CB00C10A50 /* PBXTextBookmark */ = 3A451E9C10D176CB00C10A50 /* PBXTextBookmark */;
3ABDA76A10D18625003ABED5 /* PBXTextBookmark */ = 3ABDA76A10D18625003ABED5 /* PBXTextBookmark */;
- 3ABDA76D10D18625003ABED5 /* PBXTextBookmark */ = 3ABDA76D10D18625003ABED5 /* PBXTextBookmark */;
- 3ABDA76E10D18625003ABED5 /* PBXTextBookmark */ = 3ABDA76E10D18625003ABED5 /* PBXTextBookmark */;
- 3ABDA77C10D1862E003ABED5 /* PBXTextBookmark */ = 3ABDA77C10D1862E003ABED5 /* PBXTextBookmark */;
};
sourceControlManager = 3A25814B1088BD1000126784 /* Source Control */;
userBuildSettings = {
@@ -169,34 +160,6 @@
isa = PBXCodeSenseManager;
indexTemplatePath = "";
};
- 3A25815B1088BDAC00126784 /* EGORefreshTableHeaderView.h */ = {
- isa = PBXFileReference;
- fileEncoding = 4;
- lastKnownFileType = sourcecode.c.h;
- name = EGORefreshTableHeaderView.h;
- path = "/Users/codekeeper/Documents/iPhone Dev/EGOTableViewPullRefresh/Demo/TableViewPull/Classes/RefreshTableHeaderView/EGORefreshTableHeaderView.h";
- sourceTree = "<absolute>";
- uiCtxt = {
- sepNavIntBoundsRect = "{{0, 0}, {869, 637}}";
- sepNavSelRange = "{1238, 0}";
- sepNavVisRange = "{0, 1484}";
- sepNavWindowFrame = "{{15, 82}, {1568, 944}}";
- };
- };
- 3A25815C1088BDAC00126784 /* EGORefreshTableHeaderView.m */ = {
- isa = PBXFileReference;
- fileEncoding = 4;
- lastKnownFileType = sourcecode.c.objc;
- name = EGORefreshTableHeaderView.m;
- path = "/Users/codekeeper/Documents/iPhone Dev/EGOTableViewPullRefresh/Demo/TableViewPull/Classes/RefreshTableHeaderView/EGORefreshTableHeaderView.m";
- sourceTree = "<absolute>";
- uiCtxt = {
- sepNavIntBoundsRect = "{{0, 0}, {1419, 2288}}";
- sepNavSelRange = "{6082, 0}";
- sepNavVisRange = "{3169, 2484}";
- sepNavWindowFrame = "{{89, 95}, {1310, 933}}";
- };
- };
3A3D908C11187FE7002B6585 /* TableViewPullAppDelegate.h */ = {
uiCtxt = {
sepNavIntBoundsRect = "{{0, 0}, {1235, 795}}";
@@ -209,42 +172,38 @@
uiCtxt = {
sepNavIntBoundsRect = "{{0, 0}, {1235, 858}}";
sepNavSelRange = "{0, 0}";
- sepNavVisRange = "{0, 1928}";
+ sepNavVisRange = "{55, 1880}";
sepNavWindowFrame = "{{15, 100}, {1294, 923}}";
};
};
- 3A3D908F11187FEC002B6585 /* PBXBookmark */ = {
- isa = PBXBookmark;
- fRef = 3A3D908D11187FE7002B6585 /* TableViewPullAppDelegate.m */;
- };
3A3D909C11188064002B6585 /* EGORefreshTableHeaderView.h */ = {
uiCtxt = {
sepNavIntBoundsRect = "{{0, 0}, {1235, 795}}";
- sepNavSelRange = "{0, 0}";
- sepNavVisRange = "{0, 1642}";
+ sepNavSelRange = "{1640, 0}";
+ sepNavVisRange = "{0, 1746}";
};
};
3A3D909D11188064002B6585 /* EGORefreshTableHeaderView.m */ = {
uiCtxt = {
- sepNavIntBoundsRect = "{{0, 0}, {985, 2327}}";
- sepNavSelRange = "{4806, 0}";
- sepNavVisRange = "{4373, 502}";
- sepNavWindowFrame = "{{1874, 0}, {1294, 923}}";
+ sepNavIntBoundsRect = "{{0, 0}, {908, 2288}}";
+ sepNavSelRange = "{5326, 4}";
+ sepNavVisRange = "{4912, 1062}";
+ sepNavWindowFrame = "{{2002, 6}, {1294, 923}}";
};
};
3A3D90A6111881DE002B6585 /* RootViewController.h */ = {
uiCtxt = {
- sepNavIntBoundsRect = "{{0, 0}, {712, 507}}";
- sepNavSelRange = "{1376, 0}";
- sepNavVisRange = "{748, 777}";
+ sepNavIntBoundsRect = "{{0, 0}, {1235, 795}}";
+ sepNavSelRange = "{1544, 0}";
+ sepNavVisRange = "{0, 1674}";
};
};
3A3D90A7111881DE002B6585 /* RootViewController.m */ = {
uiCtxt = {
- sepNavIntBoundsRect = "{{0, 0}, {1235, 3263}}";
- sepNavSelRange = "{3986, 0}";
- sepNavVisRange = "{5435, 1919}";
- sepNavWindowFrame = "{{15, 100}, {1294, 923}}";
+ sepNavIntBoundsRect = "{{0, 0}, {1097, 3107}}";
+ sepNavSelRange = "{6485, 0}";
+ sepNavVisRange = "{6090, 450}";
+ sepNavWindowFrame = "{{1875, -93}, {1294, 923}}";
};
};
3A3D90BC11188277002B6585 /* PBXTextBookmark */ = {
@@ -288,26 +247,6 @@
vrLen = 1500;
vrLoc = 0;
};
- 3A3D90FE11188487002B6585 /* PBXTextBookmark */ = {
- isa = PBXTextBookmark;
- fRef = 3A3D90A6111881DE002B6585 /* RootViewController.h */;
- name = "RootViewController.h: 33";
- rLen = 0;
- rLoc = 1532;
- rType = 0;
- vrLen = 1674;
- vrLoc = 0;
- };
- 3A3D90FF11188487002B6585 /* PBXTextBookmark */ = {
- isa = PBXTextBookmark;
- fRef = 3A3D90A7111881DE002B6585 /* RootViewController.m */;
- name = "RootViewController.m: 204";
- rLen = 0;
- rLoc = 6554;
- rType = 0;
- vrLen = 2001;
- vrLoc = 5059;
- };
3A3D910211188495002B6585 /* main.m */ = {
uiCtxt = {
sepNavIntBoundsRect = "{{0, 0}, {869, 510}}";
@@ -315,25 +254,6 @@
sepNavVisRange = "{0, 375}";
};
};
- 3A3D91091118849B002B6585 /* PBXTextBookmark */ = {
- isa = PBXTextBookmark;
- fRef = 3A3D90A7111881DE002B6585 /* RootViewController.m */;
- name = "RootViewController.m: 59";
- rLen = 1;
- rLoc = 2079;
- rType = 0;
- vrLen = 966;
- vrLoc = 1241;
- };
- 3A3D912211188548002B6585 /* XCBuildMessageTextBookmark */ = {
- isa = PBXTextBookmark;
- comments = "Assignment of read-only variable 'prop.171'";
- fRef = 3A3D909D11188064002B6585 /* EGORefreshTableHeaderView.m */;
- fallbackIsa = XCBuildMessageTextBookmark;
- rLen = 1;
- rLoc = 115;
- rType = 1;
- };
3A3D912911188570002B6585 /* PBXTextBookmark */ = {
isa = PBXTextBookmark;
fRef = 3A3D910211188495002B6585 /* main.m */;
@@ -344,50 +264,40 @@
vrLen = 375;
vrLoc = 0;
};
- 3A3D914B11188665002B6585 /* PBXTextBookmark */ = {
+ 3A3D943311189ADA002B6585 /* PBXTextBookmark */ = {
isa = PBXTextBookmark;
fRef = 3A3D909D11188064002B6585 /* EGORefreshTableHeaderView.m */;
- name = "EGORefreshTableHeaderView.m: 114";
+ name = "EGORefreshTableHeaderView.m: 154";
rLen = 0;
- rLoc = 4671;
+ rLoc = 5973;
rType = 0;
- vrLen = 1467;
- vrLoc = 3948;
+ vrLen = 1053;
+ vrLoc = 4930;
};
- 3A3D914C11188665002B6585 /* PBXTextBookmark */ = {
+ 3A3D946D11189C73002B6585 /* PBXTextBookmark */ = {
isa = PBXTextBookmark;
fRef = 3A3D90A7111881DE002B6585 /* RootViewController.m */;
- name = "RootViewController.m: 137";
+ name = "RootViewController.m: 184";
rLen = 0;
- rLoc = 3986;
+ rLoc = 5784;
rType = 0;
- vrLen = 1919;
- vrLoc = 5435;
+ vrLen = 1378;
+ vrLoc = 5404;
};
- 3A3D914D11188665002B6585 /* PBXTextBookmark */ = {
+ 3A3D946E11189C73002B6585 /* PBXTextBookmark */ = {
isa = PBXTextBookmark;
- fRef = 3A3D908D11187FE7002B6585 /* TableViewPullAppDelegate.m */;
- name = "TableViewPullAppDelegate.m: 1";
- rLen = 0;
- rLoc = 0;
+ fRef = 3A3D909D11188064002B6585 /* EGORefreshTableHeaderView.m */;
+ name = "EGORefreshTableHeaderView.m: 130";
+ rLen = 4;
+ rLoc = 5326;
rType = 0;
- vrLen = 1928;
- vrLoc = 0;
+ vrLen = 1062;
+ vrLoc = 4912;
};
3A451E9110D176B300C10A50 /* PBXBookmark */ = {
isa = PBXBookmark;
fRef = 3A2585541088E97000126784 /* whiteArrow.png */;
};
- 3A451E9C10D176CB00C10A50 /* PBXTextBookmark */ = {
- isa = PBXTextBookmark;
- fRef = 3A25815B1088BDAC00126784 /* EGORefreshTableHeaderView.h */;
- name = "EGORefreshTableHeaderView.h: 23";
- rLen = 0;
- rLoc = 1503;
- rType = 0;
- vrLen = 552;
- vrLoc = 0;
- };
3ABDA76A10D18625003ABED5 /* PBXTextBookmark */ = {
isa = PBXTextBookmark;
fRef = 3ABDA76B10D18625003ABED5 /* NSArrayHelper.m */;
@@ -405,46 +315,11 @@
path = "/Users/codekeeper/Downloads/enormego-cocoa-helpers-842d0df/NSArray/NSArrayHelper.m";
sourceTree = "<absolute>";
};
- 3ABDA76D10D18625003ABED5 /* PBXTextBookmark */ = {
- isa = PBXTextBookmark;
- fRef = 3A25815C1088BDAC00126784 /* EGORefreshTableHeaderView.m */;
- name = "EGORefreshTableHeaderView.m: 26";
- rLen = 0;
- rLoc = 1238;
- rType = 0;
- vrLen = 1636;
- vrLoc = 3;
- };
- 3ABDA76E10D18625003ABED5 /* PBXTextBookmark */ = {
- isa = PBXTextBookmark;
- fRef = 3A25815B1088BDAC00126784 /* EGORefreshTableHeaderView.h */;
- name = "EGORefreshTableHeaderView.h: 26";
- rLen = 0;
- rLoc = 1238;
- rType = 0;
- vrLen = 1484;
- vrLoc = 0;
- };
3ABDA77B10D1862E003ABED5 /* EGORefreshTableHeaderView.m */ = {
isa = PBXFileReference;
lastKnownFileType = sourcecode.c.objc;
name = EGORefreshTableHeaderView.m;
path = /Users/codekeeper/EGOTableViewPullRefresh/EGOTableViewPullRefresh/Classes/EGORefreshTableHeaderView.m;
sourceTree = "<absolute>";
- uiCtxt = {
- sepNavIntBoundsRect = "{{0, 0}, {869, 2262}}";
- sepNavSelRange = "{649, 0}";
- sepNavVisRange = "{0, 1638}";
- };
- };
- 3ABDA77C10D1862E003ABED5 /* PBXTextBookmark */ = {
- isa = PBXTextBookmark;
- fRef = 3A25815C1088BDAC00126784 /* EGORefreshTableHeaderView.m */;
- name = "EGORefreshTableHeaderView.m: 151";
- rLen = 0;
- rLoc = 6082;
- rType = 0;
- vrLen = 2484;
- vrLoc = 3169;
};
}
View
20 EGOTableViewPullRefresh/Classes/Controller/RootViewController.m
@@ -27,11 +27,6 @@
#import "RootViewController.h"
#import "EGORefreshTableHeaderView.h"
-#define kReleaseToReloadStatus 0
-#define kPullToReloadStatus 1
-#define kLoadingStatus 2
-
-
@interface RootViewController (Private)
- (void)dataSourceDidFinishLoadingNewData;
@@ -194,12 +189,10 @@ - (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)
- (void)scrollViewDidScroll:(UIScrollView *)scrollView{
if (scrollView.isDragging) {
- if (refreshHeaderView.isFlipped && scrollView.contentOffset.y > -65.0f && scrollView.contentOffset.y < 0.0f && !_reloading) {
- [refreshHeaderView flipImageAnimated:YES];
- [refreshHeaderView setStatus:kPullToReloadStatus];
- } else if (!refreshHeaderView.isFlipped && scrollView.contentOffset.y < -65.0f && !_reloading) {
- [refreshHeaderView flipImageAnimated:YES];
- [refreshHeaderView setStatus:kReleaseToReloadStatus];
+ if (refreshHeaderView.state == EGOOPullRefreshPulling && scrollView.contentOffset.y > -65.0f && scrollView.contentOffset.y < 0.0f && !_reloading) {
+ [refreshHeaderView setState:EGOOPullRefreshNormal];
+ } else if (refreshHeaderView.state == EGOOPullRefreshNormal && scrollView.contentOffset.y < -65.0f && !_reloading) {
+ [refreshHeaderView setState:EGOOPullRefreshPulling];
}
}
}
@@ -209,7 +202,7 @@ - (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL
if (scrollView.contentOffset.y <= - 65.0f && !_reloading) {
_reloading = YES;
[self reloadTableViewDataSource];
- [refreshHeaderView toggleActivityView];
+ [refreshHeaderView setState:EGOOPullRefreshLoading];
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.2];
self.tableView.contentInset = UIEdgeInsetsMake(60.0f, 0.0f, 0.0f, 0.0f);
@@ -226,8 +219,7 @@ - (void)dataSourceDidFinishLoadingNewData{
[self.tableView setContentInset:UIEdgeInsetsMake(0.0f, 0.0f, 0.0f, 0.0f)];
[UIView commitAnimations];
- [refreshHeaderView flipImageAnimated:NO]; // reset view
- [refreshHeaderView toggleActivityView]; // reset view
+ [refreshHeaderView setState:EGOOPullRefreshNormal];
[refreshHeaderView setCurrentDate]; // should check if data reload was successful
}
View
15 EGOTableViewPullRefresh/Classes/View/EGORefreshTableHeaderView.h
@@ -27,6 +27,13 @@
#import <UIKit/UIKit.h>
#import <QuartzCore/QuartzCore.h>
+
+typedef enum{
+ EGOOPullRefreshPulling = 0,
+ EGOOPullRefreshNormal,
+ EGOOPullRefreshLoading,
+} EGOPullRefreshState;
+
@interface EGORefreshTableHeaderView : UIView {
UILabel *lastUpdatedLabel;
@@ -34,15 +41,13 @@
CALayer *arrowImage;
UIActivityIndicatorView *activityView;
- BOOL isFlipped;
+ EGOPullRefreshState _state;
}
-@property BOOL isFlipped;
+@property(nonatomic,assign) EGOPullRefreshState state;
-- (void)flipImageAnimated:(BOOL)animated;
- (void)setCurrentDate;
-- (void)toggleActivityView;
-- (void)setStatus:(int)status;
+- (void)setState:(EGOPullRefreshState)aState;
@end
View
85 EGOTableViewPullRefresh/Classes/View/EGORefreshTableHeaderView.m
@@ -26,9 +26,6 @@
#import "EGORefreshTableHeaderView.h"
-#define kReleaseToReloadStatus 0
-#define kPullToReloadStatus 1
-#define kLoadingStatus 2
#define TEXT_COLOR [UIColor colorWithRed:87.0/255.0 green:108.0/255.0 blue:137.0/255.0 alpha:1.0]
#define BORDER_COLOR [UIColor colorWithRed:87.0/255.0 green:108.0/255.0 blue:137.0/255.0 alpha:1.0]
@@ -36,7 +33,7 @@
@implementation EGORefreshTableHeaderView
-@synthesize isFlipped;
+@synthesize state=_state;
- (id)initWithFrame:(CGRect)frame {
@@ -69,7 +66,7 @@ - (id)initWithFrame:(CGRect)frame {
statusLabel.shadowOffset = CGSizeMake(0.0f, 1.0f);
statusLabel.backgroundColor = [UIColor clearColor];
statusLabel.textAlignment = UITextAlignmentCenter;
- [self setStatus:kPullToReloadStatus];
+ [self setState:EGOOPullRefreshNormal];
[self addSubview:statusLabel];
[statusLabel release];
@@ -86,7 +83,6 @@ - (id)initWithFrame:(CGRect)frame {
[self addSubview:activityView];
[activityView release];
- isFlipped = NO;
}
return self;
}
@@ -101,26 +97,6 @@ - (void)drawRect:(CGRect)rect{
CGContextStrokePath(context);
}
-- (void)flipImageAnimated:(BOOL)animated{
-
- if (!animated) {
- [CATransaction begin];
- [CATransaction setValue:(id)kCFBooleanTrue forKey:kCATransactionDisableActions];
- arrowImage.transform = CATransform3DIdentity;
- [CATransaction commit];
- } else {
- [CATransaction begin];
- [CATransaction setAnimationDuration:animated ? .18 : 0.0];
-
- CATransform3D transform = isFlipped ? CATransform3DIdentity : CATransform3DMakeRotation((M_PI / 180.0) * 180.0f, 0.0f, 0.0f, 1.0f);
- arrowImage.transform = transform;
-
- [CATransaction commit];
- }
-
- isFlipped = !isFlipped;
-}
-
- (void)setCurrentDate {
NSDateFormatter* formatter = [[NSDateFormatter alloc] init];
[formatter setAMSymbol:@"AM"];
@@ -132,38 +108,51 @@ - (void)setCurrentDate {
[formatter release];
}
-- (void)setStatus:(int)status{
- switch (status) {
- case kReleaseToReloadStatus:
+- (void)setState:(EGOPullRefreshState)aState{
+
+ switch (aState) {
+ case EGOOPullRefreshPulling:
+
statusLabel.text = @"Release to refresh...";
+ [CATransaction begin];
+ [CATransaction setAnimationDuration:.18];
+ arrowImage.transform = CATransform3DMakeRotation((M_PI / 180.0) * 180.0f, 0.0f, 0.0f, 1.0f);
+ [CATransaction commit];
+
break;
- case kPullToReloadStatus:
+ case EGOOPullRefreshNormal:
+
+ if (_state == EGOOPullRefreshPulling) {
+ [CATransaction begin];
+ [CATransaction setAnimationDuration:.18];
+ arrowImage.transform = CATransform3DIdentity;
+ [CATransaction commit];
+ }
+
statusLabel.text = @"Pull down to refresh...";
+ [activityView stopAnimating];
+ [CATransaction begin];
+ [CATransaction setValue:(id)kCFBooleanTrue forKey:kCATransactionDisableActions];
+ arrowImage.hidden = NO;
+ arrowImage.transform = CATransform3DIdentity;
+ [CATransaction commit];
+
break;
- case kLoadingStatus:
+ case EGOOPullRefreshLoading:
+
statusLabel.text = @"Loading...";
+ [activityView startAnimating];
+ [CATransaction begin];
+ [CATransaction setValue:(id)kCFBooleanTrue forKey:kCATransactionDisableActions];
+ arrowImage.hidden = YES;
+ [CATransaction commit];
+
break;
default:
break;
}
-}
-
-- (void)toggleActivityView{
-
- [CATransaction begin];
- [CATransaction setValue:(id)kCFBooleanTrue forKey:kCATransactionDisableActions]; // kill layers implicit fade animation
-
- if ([activityView isAnimating]) {
- [activityView stopAnimating];
- arrowImage.hidden = NO;
- [self setStatus:kPullToReloadStatus];
- } else {
- [activityView startAnimating];
- arrowImage.hidden = YES;
- [self setStatus:kLoadingStatus];
- }
- [CATransaction commit];
+ _state = aState;
}
- (void)dealloc {
Please sign in to comment.
Something went wrong with that request. Please try again.