Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

added refreshEnabledProperty which allows to disable/enable refresh manually #13

Open
wants to merge 1 commit into from

2 participants

@fourplusone

No description provided.

@Hackmodford

This is exactly what I needed Thank You!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Nov 26, 2011
  1. @fourplusone
This page is out of date. Refresh to see the latest.
View
2  Classes/PullRefreshTableViewController.h
@@ -40,6 +40,7 @@
NSString *textPull;
NSString *textRelease;
NSString *textLoading;
+ BOOL refreshEnabled;
}
@property (nonatomic, retain) UIView *refreshHeaderView;
@@ -49,6 +50,7 @@
@property (nonatomic, copy) NSString *textPull;
@property (nonatomic, copy) NSString *textRelease;
@property (nonatomic, copy) NSString *textLoading;
+@property (nonatomic, assign) BOOL refreshEnabled;
- (void)setupStrings;
- (void)addPullToRefreshHeader;
View
13 Classes/PullRefreshTableViewController.m
@@ -35,7 +35,7 @@
@implementation PullRefreshTableViewController
-@synthesize textPull, textRelease, textLoading, refreshHeaderView, refreshLabel, refreshArrow, refreshSpinner;
+@synthesize textPull, textRelease, textLoading, refreshHeaderView, refreshLabel, refreshArrow, refreshSpinner, refreshEnabled;
- (id)initWithStyle:(UITableViewStyle)style {
self = [super initWithStyle:style];
@@ -70,6 +70,7 @@ - (void)setupStrings{
textPull = [[NSString alloc] initWithString:@"Pull down to refresh..."];
textRelease = [[NSString alloc] initWithString:@"Release to refresh..."];
textLoading = [[NSString alloc] initWithString:@"Loading..."];
+ refreshEnabled = YES;
}
- (void)addPullToRefreshHeader {
@@ -93,6 +94,7 @@ - (void)addPullToRefreshHeader {
[refreshHeaderView addSubview:refreshLabel];
[refreshHeaderView addSubview:refreshArrow];
[refreshHeaderView addSubview:refreshSpinner];
+ refreshHeaderView.hidden = !refreshEnabled;
[self.tableView addSubview:refreshHeaderView];
}
@@ -108,7 +110,7 @@ - (void)scrollViewDidScroll:(UIScrollView *)scrollView {
self.tableView.contentInset = UIEdgeInsetsZero;
else if (scrollView.contentOffset.y >= -REFRESH_HEADER_HEIGHT)
self.tableView.contentInset = UIEdgeInsetsMake(-scrollView.contentOffset.y, 0, 0, 0);
- } else if (isDragging && scrollView.contentOffset.y < 0) {
+ } else if (refreshEnabled && isDragging && scrollView.contentOffset.y < 0) {
// Update the arrow direction and label
[UIView beginAnimations:nil context:NULL];
if (scrollView.contentOffset.y < -REFRESH_HEADER_HEIGHT) {
@@ -126,7 +128,7 @@ - (void)scrollViewDidScroll:(UIScrollView *)scrollView {
- (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate {
if (isLoading) return;
isDragging = NO;
- if (scrollView.contentOffset.y <= -REFRESH_HEADER_HEIGHT) {
+ if (refreshEnabled && scrollView.contentOffset.y <= -REFRESH_HEADER_HEIGHT) {
// Released above the header
[self startLoading];
}
@@ -168,6 +170,11 @@ - (void)stopLoadingComplete:(NSString *)animationID finished:(NSNumber *)finishe
[refreshSpinner stopAnimating];
}
+-(void)setRefreshEnabled:(BOOL)enabled{
+ refreshEnabled = enabled;
+ refreshHeaderView.hidden = !enabled;
+}
+
- (void)refresh {
// This is just a demo. Override this method with your custom reload action.
// Don't forget to call stopLoading at the end.
Something went wrong with that request. Please try again.