Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Small performance improvement while scrolling.

commit ad6483d72778aeb9f417e538385fbff6eb377766 1 parent 516fbed
@devindoty devindoty authored
Showing with 160 additions and 5,915 deletions.
  1. +1 −1  Demo/TableViewPull/Classes/EGORefreshTableHeaderView.h
  2. +7 −10 Demo/TableViewPull/Classes/EGORefreshTableHeaderView.m
  3. +1 −0  Demo/TableViewPull/Classes/EGOTableViewPullRefresh.h
  4. +12 −11 Demo/TableViewPull/Classes/EGOTableViewPullRefresh.m
  5. 0  Demo/TableViewPull/Classes/RootViewController.h
  6. 0  Demo/TableViewPull/Classes/RootViewController.m
  7. 0  Demo/TableViewPull/Classes/TableViewPullAppDelegate.h
  8. 0  Demo/TableViewPull/Classes/TableViewPullAppDelegate.m
  9. 0  Demo/TableViewPull/MainWindow.xib
  10. 0  Demo/TableViewPull/RootViewController.xib
  11. 0  Demo/TableViewPull/TableViewPull-Info.plist
  12. +40 −39 Demo/TableViewPull/TableViewPull.xcodeproj/codekeeper.mode1v3
  13. +78 −5,832 Demo/TableViewPull/TableViewPull.xcodeproj/codekeeper.pbxuser
  14. 0  Demo/TableViewPull/TableViewPull_Prefix.pch
  15. 0  Demo/TableViewPull/blackArrow.png
  16. 0  Demo/TableViewPull/blueArrow.png
  17. 0  Demo/TableViewPull/main.m
  18. 0  Demo/TableViewPull/whiteArrow.png
  19. +1 −1  EGOTableViewPullRefresh/Classes/EGORefreshTableHeaderView.h
  20. +7 −10 EGOTableViewPullRefresh/Classes/EGORefreshTableHeaderView.m
  21. +1 −0  EGOTableViewPullRefresh/Classes/EGOTableViewPullRefresh.h
  22. +12 −11 EGOTableViewPullRefresh/Classes/EGOTableViewPullRefresh.m
  23. 0  EGOTableViewPullRefresh/Resources/blackArrow.png
  24. 0  EGOTableViewPullRefresh/Resources/blueArrow.png
  25. 0  EGOTableViewPullRefresh/Resources/whiteArrow.png
  26. 0  README
View
2  Demo/TableViewPull/Classes/EGORefreshTableHeaderView.h
@@ -1,6 +1,6 @@
//
// EGORefreshTableHeaderView.h
-// Peek
+// Demo
//
// Created by Devin Doty on 10/14/09October14.
// Copyright 2009 enormego. All rights reserved.
View
17 Demo/TableViewPull/Classes/EGORefreshTableHeaderView.m
@@ -1,6 +1,6 @@
//
// EGORefreshTableHeaderView.m
-// Peek
+// Demo
//
// Created by Devin Doty on 10/14/09October14.
// Copyright 2009 enormego. All rights reserved.
@@ -83,15 +83,11 @@ - (void)drawRect:(CGRect)rect{
- (void)flipImageAnimated:(BOOL)animated{
- if (animated) {
- [UIView beginAnimations:nil context:NULL];
- [UIView setAnimationDuration:.18];
- [arrowImage layer].transform = isFlipped ? CATransform3DMakeRotation(M_PI, 0.0f, 0.0f, 1.0f) : CATransform3DMakeRotation(M_PI * 2, 0.0f, 0.0f, 1.0f);
- [UIView commitAnimations];
- } else {
- [arrowImage layer].transform = isFlipped ? CATransform3DMakeRotation(M_PI, 0.0f, 0.0f, 1.0f) : CATransform3DMakeRotation(M_PI * 2, 0.0f, 0.0f, 1.0f);
- }
-
+ [UIView beginAnimations:nil context:NULL];
+ [UIView setAnimationDuration:animated ? .18 : 0.0];
+ [arrowImage layer].transform = isFlipped ? CATransform3DMakeRotation(M_PI, 0.0f, 0.0f, 1.0f) : CATransform3DMakeRotation(M_PI * 2, 0.0f, 0.0f, 1.0f);
+ [UIView commitAnimations];
+
isFlipped = !isFlipped;
}
@@ -102,6 +98,7 @@ - (void)setCurrentDate {
[formatter setDateFormat:@"MM/dd/yyyy hh:mm:a"];
lastUpdatedLabel.text = [NSString stringWithFormat:@"Last Updated: %@", [formatter stringFromDate:[NSDate date]]];
[[NSUserDefaults standardUserDefaults] setObject:lastUpdatedLabel.text forKey:@"EGORefreshTableView_LastRefresh"];
+ [[NSUserDefaults standardUserDefaults] synchronize];
[formatter release];
}
View
1  Demo/TableViewPull/Classes/EGOTableViewPullRefresh.h
@@ -15,6 +15,7 @@
EGORefreshTableHeaderView *refreshHeaderView;
BOOL reloading;
+ BOOL checkForRefresh;
}
- (void)dataSourceDidFinishLoadingNewData;
@end
View
23 Demo/TableViewPull/Classes/EGOTableViewPullRefresh.m
@@ -6,10 +6,6 @@
// Copyright 2009 enormego. All rights reserved.
//
-// Requires
-// NSDateHelper
-// QuartzCore.framework
-//
#import "EGOTableViewPullRefresh.h"
#import "EGORefreshTableHeaderView.h"
@@ -31,19 +27,23 @@ - (id)initWithFrame:(CGRect)frame style:(UITableViewStyle)style{
return self;
}
+- (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView;{
+ checkForRefresh = YES; // only check offset when dragging
+}
- (void)scrollViewDidScroll:(UIScrollView *)scrollView{
- 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) {
- [refreshHeaderView flipImageAnimated:YES];
- [refreshHeaderView setStatus:kReleaseToReloadStatus];
+ if (checkForRefresh) {
+ 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) {
+ [refreshHeaderView flipImageAnimated:YES];
+ [refreshHeaderView setStatus:kReleaseToReloadStatus];
+ }
}
}
- (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate{
-
if (scrollView.contentOffset.y <= - 65.0f) {
if([self.dataSource respondsToSelector:@selector(reloadTableViewDataSource)]){
reloading = YES;
@@ -55,6 +55,7 @@ - (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL
[UIView commitAnimations];
}
}
+ checkForRefresh = NO;
}
- (void)dataSourceDidFinishLoadingNewData{
View
0  Demo/TableViewPull/Classes/RootViewController.h 100644 → 100755
File mode changed
View
0  Demo/TableViewPull/Classes/RootViewController.m 100644 → 100755
File mode changed
View
0  Demo/TableViewPull/Classes/TableViewPullAppDelegate.h 100644 → 100755
File mode changed
View
0  Demo/TableViewPull/Classes/TableViewPullAppDelegate.m 100644 → 100755
File mode changed
View
0  Demo/TableViewPull/MainWindow.xib 100644 → 100755
File mode changed
View
0  Demo/TableViewPull/RootViewController.xib 100644 → 100755
File mode changed
View
0  Demo/TableViewPull/TableViewPull-Info.plist 100644 → 100755
File mode changed
View
79 Demo/TableViewPull/TableViewPull.xcodeproj/codekeeper.mode1v3 100644 → 100755
@@ -296,14 +296,14 @@
<key>PBXSmartGroupTreeModuleOutlineStateSelectionKey</key>
<array>
<array>
- <integer>7</integer>
+ <integer>6</integer>
<integer>5</integer>
<integer>1</integer>
<integer>0</integer>
</array>
</array>
<key>PBXSmartGroupTreeModuleOutlineStateVisibleRectKey</key>
- <string>{{0, 0}, {331, 445}}</string>
+ <string>{{0, 0}, {331, 734}}</string>
</dict>
<key>PBXTopSmartGroupGIDs</key>
<array/>
@@ -315,14 +315,14 @@
<key>GeometryConfiguration</key>
<dict>
<key>Frame</key>
- <string>{{0, 0}, {348, 463}}</string>
+ <string>{{0, 0}, {348, 752}}</string>
<key>GroupTreeTableConfiguration</key>
<array>
<string>MainColumn</string>
<real>331</real>
</array>
<key>RubberWindowFrame</key>
- <string>121 521 788 504 0 0 1680 1028 </string>
+ <string>121 232 1283 793 0 0 1680 1028 </string>
</dict>
<key>Module</key>
<string>PBXSmartGroupTreeModule</string>
@@ -338,7 +338,7 @@
<key>PBXProjectModuleGUID</key>
<string>1CE0B20306471E060097A5F4</string>
<key>PBXProjectModuleLabel</key>
- <string>EGORefreshTableHeaderView.m</string>
+ <string>EGORefreshTableHeaderView.h</string>
<key>PBXSplitModuleInNavigatorKey</key>
<dict>
<key>Split0</key>
@@ -346,21 +346,22 @@
<key>PBXProjectModuleGUID</key>
<string>1CE0B20406471E060097A5F4</string>
<key>PBXProjectModuleLabel</key>
- <string>EGORefreshTableHeaderView.m</string>
+ <string>EGORefreshTableHeaderView.h</string>
<key>_historyCapacity</key>
<integer>0</integer>
<key>bookmark</key>
- <string>3A2587111088F69300126784</string>
+ <string>3AC3B09210974574009D9249</string>
<key>history</key>
<array>
<string>3A2586091088EDA100126784</string>
<string>3A25860A1088EDA100126784</string>
<string>3A25860B1088EDA100126784</string>
<string>3A25860C1088EDA100126784</string>
- <string>3A2587091088F68100126784</string>
- <string>3A25870A1088F68100126784</string>
- <string>3A25870B1088F68100126784</string>
- <string>3A2581D81088C32F00126784</string>
+ <string>3AC3B0891097456F009D9249</string>
+ <string>3AC3B08B1097456F009D9249</string>
+ <string>3AC3B08C1097456F009D9249</string>
+ <string>3AC3B08D1097456F009D9249</string>
+ <string>3AC3B08E1097456F009D9249</string>
</array>
</dict>
<key>SplitCount</key>
@@ -372,14 +373,14 @@
<key>GeometryConfiguration</key>
<dict>
<key>Frame</key>
- <string>{{0, 0}, {435, 277}}</string>
+ <string>{{0, 0}, {930, 558}}</string>
<key>RubberWindowFrame</key>
- <string>121 521 788 504 0 0 1680 1028 </string>
+ <string>121 232 1283 793 0 0 1680 1028 </string>
</dict>
<key>Module</key>
<string>PBXNavigatorGroup</string>
<key>Proportion</key>
- <string>277pt</string>
+ <string>558pt</string>
</dict>
<dict>
<key>ContentConfiguration</key>
@@ -392,18 +393,18 @@
<key>GeometryConfiguration</key>
<dict>
<key>Frame</key>
- <string>{{0, 282}, {435, 181}}</string>
+ <string>{{0, 563}, {930, 189}}</string>
<key>RubberWindowFrame</key>
- <string>121 521 788 504 0 0 1680 1028 </string>
+ <string>121 232 1283 793 0 0 1680 1028 </string>
</dict>
<key>Module</key>
<string>XCDetailModule</string>
<key>Proportion</key>
- <string>181pt</string>
+ <string>189pt</string>
</dict>
</array>
<key>Proportion</key>
- <string>435pt</string>
+ <string>930pt</string>
</dict>
</array>
<key>Name</key>
@@ -418,9 +419,9 @@
</array>
<key>TableOfContents</key>
<array>
- <string>3A2581B21088C1D200126784</string>
+ <string>3AC3B0601097432F009D9249</string>
<string>1CE0B1FE06471DED0097A5F4</string>
- <string>3A2581B31088C1D200126784</string>
+ <string>3AC3B0611097432F009D9249</string>
<string>1CE0B20306471E060097A5F4</string>
<string>1CE0B20506471E060097A5F4</string>
</array>
@@ -541,7 +542,7 @@
<key>StatusbarIsVisible</key>
<true/>
<key>TimeStamp</key>
- <real>277411475.26656902</real>
+ <real>278349172.110636</real>
<key>ToolbarConfigUserDefaultsMinorVersion</key>
<string>2</string>
<key>ToolbarDisplayMode</key>
@@ -561,10 +562,10 @@
<string>1C78EAAD065D492600B07095</string>
<string>1CD10A99069EF8BA00B06720</string>
<string>3A2581631088BE7100126784</string>
- <string>/Users/codekeeper/Documents/iPhone Dev/TableViewPull/TableViewPull.xcodeproj</string>
+ <string>/Users/codekeeper/Desktop/enormego-EGOTableViewPullRefresh-516fbed-1/Demo/TableViewPull/TableViewPull.xcodeproj</string>
</array>
<key>WindowString</key>
- <string>121 521 788 504 0 0 1680 1028 </string>
+ <string>121 232 1283 793 0 0 1680 1028 </string>
<key>WindowToolsV3</key>
<array>
<dict>
@@ -580,14 +581,12 @@
<key>Dock</key>
<array>
<dict>
- <key>BecomeActive</key>
- <true/>
<key>ContentConfiguration</key>
<dict>
<key>PBXProjectModuleGUID</key>
<string>1CD0528F0623707200166675</string>
<key>PBXProjectModuleLabel</key>
- <string>EGOTableViewPullRefresh.m</string>
+ <string></string>
<key>StatusBarVisibility</key>
<true/>
</dict>
@@ -604,6 +603,8 @@
<string>218pt</string>
</dict>
<dict>
+ <key>BecomeActive</key>
+ <true/>
<key>ContentConfiguration</key>
<dict>
<key>PBXProjectModuleGUID</key>
@@ -643,7 +644,7 @@
<key>TableOfContents</key>
<array>
<string>3A2581631088BE7100126784</string>
- <string>3A2581641088BE7100126784</string>
+ <string>3AC3B05B10974251009D9249</string>
<string>1CD0528F0623707200166675</string>
<string>XCMainBuildResultsModuleGUID</string>
</array>
@@ -687,8 +688,8 @@
<string>yes</string>
<key>sizes</key>
<array>
- <string>{{0, 0}, {316, 185}}</string>
- <string>{{316, 0}, {378, 185}}</string>
+ <string>{{0, 0}, {316, 194}}</string>
+ <string>{{316, 0}, {378, 194}}</string>
</array>
</dict>
<key>VerticalSplitView</key>
@@ -703,8 +704,8 @@
<string>yes</string>
<key>sizes</key>
<array>
- <string>{{0, 0}, {694, 185}}</string>
- <string>{{0, 185}, {694, 196}}</string>
+ <string>{{0, 0}, {694, 194}}</string>
+ <string>{{0, 194}, {694, 187}}</string>
</array>
</dict>
</dict>
@@ -737,7 +738,7 @@
<real>148</real>
</array>
<key>Frame</key>
- <string>{{316, 0}, {378, 185}}</string>
+ <string>{{316, 0}, {378, 194}}</string>
<key>RubberWindowFrame</key>
<string>886 411 694 422 0 0 1680 1028 </string>
</dict>
@@ -765,13 +766,13 @@
<key>TableOfContents</key>
<array>
<string>1CD10A99069EF8BA00B06720</string>
- <string>3A2583E51088D9F100126784</string>
+ <string>3AC3B06C1097432F009D9249</string>
<string>1C162984064C10D400B95A72</string>
- <string>3A2583E61088D9F100126784</string>
- <string>3A2583E71088D9F100126784</string>
- <string>3A2583E81088D9F100126784</string>
- <string>3A2583E91088D9F100126784</string>
- <string>3A2583EA1088D9F100126784</string>
+ <string>3AC3B06D1097432F009D9249</string>
+ <string>3AC3B06E1097432F009D9249</string>
+ <string>3AC3B06F1097432F009D9249</string>
+ <string>3AC3B0701097432F009D9249</string>
+ <string>3AC3B0711097432F009D9249</string>
</array>
<key>ToolbarConfiguration</key>
<string>xcode.toolbar.config.debugV3</string>
@@ -935,7 +936,7 @@
<key>TableOfContents</key>
<array>
<string>1C78EAAD065D492600B07095</string>
- <string>3A2583EB1088D9F100126784</string>
+ <string>3AC3B0721097432F009D9249</string>
<string>1C78EAAC065D492600B07095</string>
</array>
<key>ToolbarConfiguration</key>
View
5,910 Demo/TableViewPull/TableViewPull.xcodeproj/codekeeper.pbxuser 100644 → 100755
78 additions, 5,832 deletions not shown
View
0  Demo/TableViewPull/TableViewPull_Prefix.pch 100644 → 100755
File mode changed
View
0  Demo/TableViewPull/blackArrow.png 100644 → 100755
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
0  Demo/TableViewPull/blueArrow.png 100644 → 100755
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
0  Demo/TableViewPull/main.m 100644 → 100755
File mode changed
View
0  Demo/TableViewPull/whiteArrow.png 100644 → 100755
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
2  EGOTableViewPullRefresh/Classes/EGORefreshTableHeaderView.h 100644 → 100755
@@ -1,6 +1,6 @@
//
// EGORefreshTableHeaderView.h
-// Peek
+// Demo
//
// Created by Devin Doty on 10/14/09October14.
// Copyright 2009 enormego. All rights reserved.
View
17 EGOTableViewPullRefresh/Classes/EGORefreshTableHeaderView.m 100644 → 100755
@@ -1,6 +1,6 @@
//
// EGORefreshTableHeaderView.m
-// Peek
+// Demo
//
// Created by Devin Doty on 10/14/09October14.
// Copyright 2009 enormego. All rights reserved.
@@ -83,15 +83,11 @@ - (void)drawRect:(CGRect)rect{
- (void)flipImageAnimated:(BOOL)animated{
- if (animated) {
- [UIView beginAnimations:nil context:NULL];
- [UIView setAnimationDuration:.18];
- [arrowImage layer].transform = isFlipped ? CATransform3DMakeRotation(M_PI, 0.0f, 0.0f, 1.0f) : CATransform3DMakeRotation(M_PI * 2, 0.0f, 0.0f, 1.0f);
- [UIView commitAnimations];
- } else {
- [arrowImage layer].transform = isFlipped ? CATransform3DMakeRotation(M_PI, 0.0f, 0.0f, 1.0f) : CATransform3DMakeRotation(M_PI * 2, 0.0f, 0.0f, 1.0f);
- }
-
+ [UIView beginAnimations:nil context:NULL];
+ [UIView setAnimationDuration:animated ? .18 : 0.0];
+ [arrowImage layer].transform = isFlipped ? CATransform3DMakeRotation(M_PI, 0.0f, 0.0f, 1.0f) : CATransform3DMakeRotation(M_PI * 2, 0.0f, 0.0f, 1.0f);
+ [UIView commitAnimations];
+
isFlipped = !isFlipped;
}
@@ -102,6 +98,7 @@ - (void)setCurrentDate {
[formatter setDateFormat:@"MM/dd/yyyy hh:mm:a"];
lastUpdatedLabel.text = [NSString stringWithFormat:@"Last Updated: %@", [formatter stringFromDate:[NSDate date]]];
[[NSUserDefaults standardUserDefaults] setObject:lastUpdatedLabel.text forKey:@"EGORefreshTableView_LastRefresh"];
+ [[NSUserDefaults standardUserDefaults] synchronize];
[formatter release];
}
View
1  EGOTableViewPullRefresh/Classes/EGOTableViewPullRefresh.h 100644 → 100755
@@ -15,6 +15,7 @@
EGORefreshTableHeaderView *refreshHeaderView;
BOOL reloading;
+ BOOL checkForRefresh;
}
- (void)dataSourceDidFinishLoadingNewData;
@end
View
23 EGOTableViewPullRefresh/Classes/EGOTableViewPullRefresh.m 100644 → 100755
@@ -6,10 +6,6 @@
// Copyright 2009 enormego. All rights reserved.
//
-// Requires
-// NSDateHelper
-// QuartzCore.framework
-//
#import "EGOTableViewPullRefresh.h"
#import "EGORefreshTableHeaderView.h"
@@ -31,19 +27,23 @@ - (id)initWithFrame:(CGRect)frame style:(UITableViewStyle)style{
return self;
}
+- (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView;{
+ checkForRefresh = YES; // only check offset when dragging
+}
- (void)scrollViewDidScroll:(UIScrollView *)scrollView{
- 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) {
- [refreshHeaderView flipImageAnimated:YES];
- [refreshHeaderView setStatus:kReleaseToReloadStatus];
+ if (checkForRefresh) {
+ 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) {
+ [refreshHeaderView flipImageAnimated:YES];
+ [refreshHeaderView setStatus:kReleaseToReloadStatus];
+ }
}
}
- (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate{
-
if (scrollView.contentOffset.y <= - 65.0f) {
if([self.dataSource respondsToSelector:@selector(reloadTableViewDataSource)]){
reloading = YES;
@@ -55,6 +55,7 @@ - (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL
[UIView commitAnimations];
}
}
+ checkForRefresh = NO;
}
- (void)dataSourceDidFinishLoadingNewData{
View
0  EGOTableViewPullRefresh/Resources/blackArrow.png 100644 → 100755
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
0  EGOTableViewPullRefresh/Resources/blueArrow.png 100644 → 100755
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
0  EGOTableViewPullRefresh/Resources/whiteArrow.png 100644 → 100755
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
0  README 100644 → 100755
File mode changed
Please sign in to comment.
Something went wrong with that request. Please try again.