fix refresh issue

This commit is contained in:
Steven Zweier 2016-02-23 09:49:40 -05:00
parent 15bd513774
commit c41c5bd3ad
3 changed files with 14 additions and 3 deletions

View File

@ -15,6 +15,7 @@
@interface TLYShyScrollViewController : NSObject <TLYShyChild>
@property (nonatomic, weak) UIScrollView *scrollView;
@property (nonatomic, weak) UIRefreshControl *refreshControl;
@property (nonatomic, weak) TLYShyViewController *parent;
- (CGFloat)updateLayoutIfNeeded;

View File

@ -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;
}

View File

@ -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;