diff --git a/Demo/TableViewPull/Classes/View/RefreshTableHeaderView/EGORefreshTableHeaderView.h b/Demo/TableViewPull/Classes/View/RefreshTableHeaderView/EGORefreshTableHeaderView.h index 82077db..0ec72f0 100755 --- a/Demo/TableViewPull/Classes/View/RefreshTableHeaderView/EGORefreshTableHeaderView.h +++ b/Demo/TableViewPull/Classes/View/RefreshTableHeaderView/EGORefreshTableHeaderView.h @@ -49,6 +49,8 @@ typedef enum{ @property(nonatomic,assign) id delegate; +- (id)initWithFrame:(CGRect)frame arrowImageName:(NSString *)arrow textColor:(UIColor *)textColor; + - (void)refreshLastUpdatedDate; - (void)egoRefreshScrollViewDidScroll:(UIScrollView *)scrollView; - (void)egoRefreshScrollViewDidEndDragging:(UIScrollView *)scrollView; diff --git a/Demo/TableViewPull/Classes/View/RefreshTableHeaderView/EGORefreshTableHeaderView.m b/Demo/TableViewPull/Classes/View/RefreshTableHeaderView/EGORefreshTableHeaderView.m index 0def219..91ae8a5 100755 --- a/Demo/TableViewPull/Classes/View/RefreshTableHeaderView/EGORefreshTableHeaderView.m +++ b/Demo/TableViewPull/Classes/View/RefreshTableHeaderView/EGORefreshTableHeaderView.m @@ -40,8 +40,8 @@ @implementation EGORefreshTableHeaderView @synthesize delegate=_delegate; -- (id)initWithFrame:(CGRect)frame { - if (self = [super initWithFrame:frame]) { +- (id)initWithFrame:(CGRect)frame arrowImageName:(NSString *)arrow textColor:(UIColor *)textColor { + if((self = [super initWithFrame:frame])) { self.autoresizingMask = UIViewAutoresizingFlexibleWidth; self.backgroundColor = [UIColor colorWithRed:226.0/255.0 green:231.0/255.0 blue:237.0/255.0 alpha:1.0]; @@ -49,7 +49,7 @@ - (id)initWithFrame:(CGRect)frame { UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0.0f, frame.size.height - 30.0f, self.frame.size.width, 20.0f)]; label.autoresizingMask = UIViewAutoresizingFlexibleWidth; label.font = [UIFont systemFontOfSize:12.0f]; - label.textColor = TEXT_COLOR; + label.textColor = textColor; label.shadowColor = [UIColor colorWithWhite:0.9f alpha:1.0f]; label.shadowOffset = CGSizeMake(0.0f, 1.0f); label.backgroundColor = [UIColor clearColor]; @@ -61,7 +61,7 @@ - (id)initWithFrame:(CGRect)frame { label = [[UILabel alloc] initWithFrame:CGRectMake(0.0f, frame.size.height - 48.0f, self.frame.size.width, 20.0f)]; label.autoresizingMask = UIViewAutoresizingFlexibleWidth; label.font = [UIFont boldSystemFontOfSize:13.0f]; - label.textColor = TEXT_COLOR; + label.textColor = textColor; label.shadowColor = [UIColor colorWithWhite:0.9f alpha:1.0f]; label.shadowOffset = CGSizeMake(0.0f, 1.0f); label.backgroundColor = [UIColor clearColor]; @@ -73,7 +73,7 @@ - (id)initWithFrame:(CGRect)frame { CALayer *layer = [CALayer layer]; layer.frame = CGRectMake(25.0f, frame.size.height - 65.0f, 30.0f, 55.0f); layer.contentsGravity = kCAGravityResizeAspect; - layer.contents = (id)[UIImage imageNamed:@"blueArrow.png"].CGImage; + layer.contents = (id)[UIImage imageNamed:arrow].CGImage; #if __IPHONE_OS_VERSION_MAX_ALLOWED >= 40000 if ([[UIScreen mainScreen] respondsToSelector:@selector(scale)]) { @@ -99,6 +99,9 @@ - (id)initWithFrame:(CGRect)frame { } +- (id)initWithFrame:(CGRect)frame { + return [self initWithFrame:frame arrowImageName:@"blueArrow.png" textColor:TEXT_COLOR]; +} #pragma mark - #pragma mark Setters @@ -109,14 +112,14 @@ - (void)refreshLastUpdatedDate { NSDate *date = [_delegate egoRefreshTableHeaderDataSourceLastUpdated:self]; - NSDateFormatter *formatter = [[NSDateFormatter alloc] init]; - [formatter setAMSymbol:@"AM"]; - [formatter setPMSymbol:@"PM"]; - [formatter setDateFormat:@"MM/dd/yyyy hh:mm:a"]; - _lastUpdatedLabel.text = [NSString stringWithFormat:@"Last Updated: %@", [formatter stringFromDate:date]]; + [NSDateFormatter setDefaultFormatterBehavior:NSDateFormatterBehaviorDefault]; + NSDateFormatter *dateFormatter = [[[NSDateFormatter alloc] init] autorelease]; + [dateFormatter setDateStyle:NSDateFormatterShortStyle]; + [dateFormatter setTimeStyle:NSDateFormatterShortStyle]; + + _lastUpdatedLabel.text = [NSString stringWithFormat:@"Last Updated: %@", [dateFormatter stringFromDate:date]]; [[NSUserDefaults standardUserDefaults] setObject:_lastUpdatedLabel.text forKey:@"EGORefreshTableView_LastRefresh"]; [[NSUserDefaults standardUserDefaults] synchronize]; - [formatter release]; } else { @@ -154,8 +157,9 @@ - (void)setState:(EGOPullRefreshState)aState{ _arrowImage.hidden = NO; _arrowImage.transform = CATransform3DIdentity; [CATransaction commit]; - - [self refreshLastUpdatedDate]; + + if (_state == EGOOPullRefreshLoading) + [self refreshLastUpdatedDate]; break; case EGOOPullRefreshLoading: diff --git a/Demo/TableViewPull/TableViewPull.xcodeproj/project.pbxproj b/Demo/TableViewPull/TableViewPull.xcodeproj/project.pbxproj index f4b157e..9d3f560 100755 --- a/Demo/TableViewPull/TableViewPull.xcodeproj/project.pbxproj +++ b/Demo/TableViewPull/TableViewPull.xcodeproj/project.pbxproj @@ -272,6 +272,7 @@ INFOPLIST_FILE = "Resources/TableViewPull-Info.plist"; IPHONEOS_DEPLOYMENT_TARGET = 3.0; PRODUCT_NAME = TableViewPull; + SDKROOT = iphoneos; TARGETED_DEVICE_FAMILY = "1,2"; }; name = Debug; @@ -286,6 +287,7 @@ INFOPLIST_FILE = "Resources/TableViewPull-Info.plist"; IPHONEOS_DEPLOYMENT_TARGET = 3.0; PRODUCT_NAME = TableViewPull; + SDKROOT = iphoneos; TARGETED_DEVICE_FAMILY = "1,2"; }; name = Release; diff --git a/EGOTableViewPullRefresh/Classes/View/EGORefreshTableHeaderView.m b/EGOTableViewPullRefresh/Classes/View/EGORefreshTableHeaderView.m index 56b345b..91ae8a5 100755 --- a/EGOTableViewPullRefresh/Classes/View/EGORefreshTableHeaderView.m +++ b/EGOTableViewPullRefresh/Classes/View/EGORefreshTableHeaderView.m @@ -157,8 +157,9 @@ - (void)setState:(EGOPullRefreshState)aState{ _arrowImage.hidden = NO; _arrowImage.transform = CATransform3DIdentity; [CATransaction commit]; - - [self refreshLastUpdatedDate]; + + if (_state == EGOOPullRefreshLoading) + [self refreshLastUpdatedDate]; break; case EGOOPullRefreshLoading: