From c41c5bd3ad540109466866f3a30f5ec46b8c202e Mon Sep 17 00:00:00 2001 From: Steven Zweier Date: Tue, 23 Feb 2016 09:49:40 -0500 Subject: [PATCH] fix refresh issue --- TLYShyNavBar/ShyControllers/TLYShyScrollViewController.h | 1 + TLYShyNavBar/ShyControllers/TLYShyScrollViewController.m | 9 ++++++--- TLYShyNavBar/TLYShyNavBarManager.m | 7 +++++++ 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/TLYShyNavBar/ShyControllers/TLYShyScrollViewController.h b/TLYShyNavBar/ShyControllers/TLYShyScrollViewController.h index ee81d81..594c019 100644 --- a/TLYShyNavBar/ShyControllers/TLYShyScrollViewController.h +++ b/TLYShyNavBar/ShyControllers/TLYShyScrollViewController.h @@ -15,6 +15,7 @@ @interface TLYShyScrollViewController : NSObject @property (nonatomic, weak) UIScrollView *scrollView; +@property (nonatomic, weak) UIRefreshControl *refreshControl; @property (nonatomic, weak) TLYShyViewController *parent; - (CGFloat)updateLayoutIfNeeded; diff --git a/TLYShyNavBar/ShyControllers/TLYShyScrollViewController.m b/TLYShyNavBar/ShyControllers/TLYShyScrollViewController.m index 90805aa..58f1be0 100644 --- a/TLYShyNavBar/ShyControllers/TLYShyScrollViewController.m +++ b/TLYShyNavBar/ShyControllers/TLYShyScrollViewController.m @@ -19,10 +19,10 @@ - (CGFloat)updateLayoutIfNeeded { - if ((self.scrollView.contentSize.height < FLT_EPSILON + if (self.scrollView.contentSize.height < FLT_EPSILON && ([self.scrollView isKindOfClass:[UITableView class]] || [self.scrollView isKindOfClass:[UICollectionView class]]) - ) || (self.scrollView.contentOffset.y <= -64)) + ) { return 0.f; } @@ -35,7 +35,10 @@ if (normalizedY > -FLT_EPSILON && !UIEdgeInsetsEqualToEdgeInsets(insets, self.scrollView.contentInset)) { CGFloat delta = insets.top - self.scrollView.contentInset.top; - [self.scrollView tly_setInsets:insets]; + + if (self.refreshControl == nil || [self.refreshControl isHidden]) { + [self.scrollView tly_setInsets:insets]; + } return delta; } diff --git a/TLYShyNavBar/TLYShyNavBarManager.m b/TLYShyNavBar/TLYShyNavBarManager.m index 0be7c8a..72a7e19 100644 --- a/TLYShyNavBar/TLYShyNavBarManager.m +++ b/TLYShyNavBar/TLYShyNavBarManager.m @@ -152,6 +152,13 @@ static void * const kTLYShyNavBarManagerKVOContext = (void*)&kTLYShyNavBarManage _scrollView = scrollView; self.scrollViewController.scrollView = scrollView; + NSUInteger index = [scrollView.subviews indexOfObjectPassingTest:^BOOL (id obj, NSUInteger idx, BOOL *stop) { + return [obj isKindOfClass:[UIRefreshControl class]]; + }]; + if (index != NSNotFound) { + self.scrollViewController.refreshControl = [scrollView.subviews objectAtIndex:index]; + } + if (_scrollView.delegate != self.delegateProxy) { self.delegateProxy.originalDelegate = _scrollView.delegate;