From 62ce81dfa0ff475b3995677c78019d90bf87caff Mon Sep 17 00:00:00 2001 From: Brock Boland Date: Tue, 22 Nov 2016 10:44:25 -0600 Subject: [PATCH 1/5] Switched paging accessory to use autolayout --- .../VOKDefaultPagingAccessory.m | 78 +++++- .../VOKPagingFetchedResultsDataSource.m | 228 ++++++++++++------ 2 files changed, 227 insertions(+), 79 deletions(-) diff --git a/Pod/Classes/Optional Data Sources/VOKDefaultPagingAccessory.m b/Pod/Classes/Optional Data Sources/VOKDefaultPagingAccessory.m index 1841eb9..5e7be5b 100755 --- a/Pod/Classes/Optional Data Sources/VOKDefaultPagingAccessory.m +++ b/Pod/Classes/Optional Data Sources/VOKDefaultPagingAccessory.m @@ -10,7 +10,7 @@ @interface VOKDefaultPagingAccessory () -@property UIActivityIndicatorView *indicator; +@property (nonatomic) UIActivityIndicatorView *indicator; @end @@ -25,10 +25,8 @@ - (void)didMoveToSuperview UILabel *label = [[UILabel alloc] initWithFrame:(CGRect){CGPointZero, self.frame.size}]; [label setText:@"Pull To Load"]; [label setFont:[UIFont boldSystemFontOfSize:20]]; - [label setTextAlignment:NSTextAlignmentCenter]; - [self addSubview:label]; [label sizeToFit]; - [label setCenter:CGPointMake(self.frame.size.width/2, self.frame.size.height/2)]; + label.translatesAutoresizingMaskIntoConstraints = NO; UIActivityIndicatorViewStyle indicatorStyle; #if TARGET_OS_IOS @@ -40,9 +38,77 @@ - (void)didMoveToSuperview self.indicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:indicatorStyle]; [self.indicator setTintColor:[UIColor blackColor]]; [self.indicator setHidesWhenStopped:NO]; + self.indicator.translatesAutoresizingMaskIntoConstraints = NO; - [self.indicator setCenter:CGPointMake(label.frame.origin.x - self.indicator.frame.size.width, self.frame.size.height/2)]; - [self addSubview:self.indicator]; + // Wrap the label and activity indicator in a parent view to be collectively centered + UIView *containerView = [[UIView alloc] init]; + containerView.translatesAutoresizingMaskIntoConstraints = NO; + [containerView addSubview:self.indicator]; + [containerView addSubview:label]; + [self addSubview:containerView]; + + // Position the activity indicator and label + [containerView addConstraint:[NSLayoutConstraint constraintWithItem:containerView + attribute:NSLayoutAttributeLeading + relatedBy:NSLayoutRelationEqual + toItem:self.indicator + attribute:NSLayoutAttributeLeading + multiplier:1 + constant:0]]; + [containerView addConstraint:[NSLayoutConstraint constraintWithItem:containerView + attribute:NSLayoutAttributeTrailing + relatedBy:NSLayoutRelationEqual + toItem:label + attribute:NSLayoutAttributeTrailing + multiplier:1 + constant:0]]; + // Put a little space between the lable and activity indicator + [containerView addConstraint:[NSLayoutConstraint constraintWithItem:label + attribute:NSLayoutAttributeLeading + relatedBy:NSLayoutRelationEqual + toItem:self.indicator + attribute:NSLayoutAttributeTrailing + multiplier:1 + constant:20]]; + + // Vertically center the indicator and label inside the container + [containerView addConstraint:[NSLayoutConstraint constraintWithItem:label + attribute:NSLayoutAttributeCenterY + relatedBy:NSLayoutRelationEqual + toItem:containerView + attribute:NSLayoutAttributeCenterY + multiplier:1 + constant:0]]; + [containerView addConstraint:[NSLayoutConstraint constraintWithItem:self.indicator + attribute:NSLayoutAttributeCenterY + relatedBy:NSLayoutRelationEqual + toItem:containerView + attribute:NSLayoutAttributeCenterY + multiplier:1 + constant:0]]; + + // Make the container fill this view, and center it horizontally + [self addConstraint:[NSLayoutConstraint constraintWithItem:containerView + attribute:NSLayoutAttributeTop + relatedBy:NSLayoutRelationEqual + toItem:self + attribute:NSLayoutAttributeTop + multiplier:1 + constant:0]]; + [self addConstraint:[NSLayoutConstraint constraintWithItem:containerView + attribute:NSLayoutAttributeBottom + relatedBy:NSLayoutRelationEqual + toItem:self + attribute:NSLayoutAttributeBottom + multiplier:1 + constant:0]]; + [self addConstraint:[NSLayoutConstraint constraintWithItem:containerView + attribute:NSLayoutAttributeCenterX + relatedBy:NSLayoutRelationEqual + toItem:self + attribute:NSLayoutAttributeCenterX + multiplier:1 + constant:0]]; } } diff --git a/Pod/Classes/Optional Data Sources/VOKPagingFetchedResultsDataSource.m b/Pod/Classes/Optional Data Sources/VOKPagingFetchedResultsDataSource.m index dc8f67c..9106d8e 100755 --- a/Pod/Classes/Optional Data Sources/VOKPagingFetchedResultsDataSource.m +++ b/Pod/Classes/Optional Data Sources/VOKPagingFetchedResultsDataSource.m @@ -14,14 +14,15 @@ @interface VOKPagingFetchedResultsDataSource () -@property (copy) VOKPagingResultsAction upAction; -@property (copy) VOKPagingResultsAction downAction; +@property (nonatomic, copy) VOKPagingResultsAction upAction; +@property (nonatomic, copy) VOKPagingResultsAction downAction; @property (nonatomic) UIView *headerView; @property (nonatomic) UIView *footerView; @property (nonatomic) BOOL isLoading; @property (nonatomic) CGFloat triggerDistance; +@property (nonatomic) NSLayoutConstraint *bottomConstraint; @property (nonatomic) UIEdgeInsets orginalInsets; @end @@ -38,43 +39,103 @@ - (void)setupForTriggerDistance:(CGFloat)overscrollTriggerDistance { self.upAction = upPageActionOrNil; self.downAction = downPageActionOrNil; - + self.headerView = headerViewOrNil; self.footerView = footerViewOrNil; - + self.isLoading = NO; - + self.triggerDistance = overscrollTriggerDistance; self.orginalInsets = self.tableView.contentInset; - + [self setupAccessoryViews]; - } - (void)setupAccessoryViews { //Attach given views, or generate default views. if (!self.headerView) { - CGRect headerFrame = (CGRect){0, -DefaultAccessoryHeight, self.tableView.frame.size.width, DefaultAccessoryHeight}; - self.headerView = [[VOKDefaultPagingAccessory alloc] initWithFrame:headerFrame]; + self.headerView = [[VOKDefaultPagingAccessory alloc] init]; + self.headerView.translatesAutoresizingMaskIntoConstraints = NO; + [self.headerView addConstraint:[NSLayoutConstraint constraintWithItem:self.headerView + attribute:NSLayoutAttributeHeight + relatedBy:NSLayoutRelationEqual + toItem:nil + attribute:0 + multiplier:1 + constant:DefaultAccessoryHeight]]; } - - self.headerView.frame = (CGRect){0, -self.headerView.frame.size.height, self.headerView.frame.size}; - [self.tableView addSubview:self.headerView]; - + + self.tableView.tableHeaderView = self.headerView; + + [self.tableView addConstraint:[NSLayoutConstraint constraintWithItem:self.headerView + attribute:NSLayoutAttributeWidth + relatedBy:NSLayoutRelationEqual + toItem:self.tableView + attribute:NSLayoutAttributeWidth + multiplier:1 + constant:0]]; + [self.tableView addConstraint:[NSLayoutConstraint constraintWithItem:self.headerView + attribute:NSLayoutAttributeLeft + relatedBy:NSLayoutRelationEqual + toItem:self.tableView + attribute:NSLayoutAttributeLeft + multiplier:1 + constant:0]]; + [self.tableView addConstraint:[NSLayoutConstraint constraintWithItem:self.headerView + attribute:NSLayoutAttributeTop + relatedBy:NSLayoutRelationEqual + toItem:self.tableView + attribute:NSLayoutAttributeTop + multiplier:1 + constant:0]]; + + UIEdgeInsets insets = self.tableView.contentInset; + insets.top -= DefaultAccessoryHeight; + if (!self.footerView) { - CGRect footerFrame = (CGRect){0, - MAX(self.tableView.contentSize.height, self.tableView.bounds.size.height), - self.tableView.frame.size.width, - DefaultAccessoryHeight}; - self.footerView = [[VOKDefaultPagingAccessory alloc] initWithFrame:footerFrame]; + self.footerView = [[VOKDefaultPagingAccessory alloc] init]; + self.footerView.translatesAutoresizingMaskIntoConstraints = NO; + [self.footerView addConstraint:[NSLayoutConstraint constraintWithItem:self.footerView + attribute:NSLayoutAttributeHeight + relatedBy:NSLayoutRelationEqual + toItem:nil + attribute:0 + multiplier:1 + constant:DefaultAccessoryHeight]]; } - - [self.tableView addSubview:self.footerView]; - + + self.tableView.tableFooterView = self.footerView; + [self.tableView addConstraint:[NSLayoutConstraint constraintWithItem:self.footerView + attribute:NSLayoutAttributeWidth + relatedBy:NSLayoutRelationEqual + toItem:self.tableView + attribute:NSLayoutAttributeWidth + multiplier:1 + constant:0]]; + [self.tableView addConstraint:[NSLayoutConstraint constraintWithItem:self.footerView + attribute:NSLayoutAttributeLeft + relatedBy:NSLayoutRelationEqual + toItem:self.tableView + attribute:NSLayoutAttributeLeft + multiplier:1 + constant:0]]; + + self.bottomConstraint = [NSLayoutConstraint constraintWithItem:self.footerView + attribute:NSLayoutAttributeBottom + relatedBy:NSLayoutRelationEqual + toItem:self.headerView + attribute:NSLayoutAttributeTop + multiplier:1 + constant:self.tableView.contentSize.height]; + [self.tableView addConstraint:self.bottomConstraint]; + + insets.bottom -= DefaultAccessoryHeight; + self.tableView.contentInset = insets; + [self.tableView addObserver:self forKeyPath:VOKKeyForInstanceOf(UITableView, contentSize) - options:NSKeyValueObservingOptionNew | NSKeyValueObservingOptionOld | NSKeyValueObservingOptionPrior + options:0 // Don't use the old or new value from the dictionary in the method, so pass 0 context:NULL]; } @@ -82,10 +143,10 @@ - (void)cleanUpPageController { [self.headerView removeFromSuperview]; self.headerView = nil; - + [self.footerView removeFromSuperview]; self.footerView = nil; - + self.upAction = nil; self.downAction = nil; } @@ -98,34 +159,49 @@ - (void)observeValueForKeyPath:(NSString *)keyPath context:(void *)context { if ([keyPath isEqualToString:VOKKeyForInstanceOf(UITableView, contentSize)]) { - self.footerView.frame = (CGRect){0, MAX(self.tableView.contentSize.height, self.tableView.bounds.size.height), self.footerView.frame.size}; + self.bottomConstraint.constant = self.tableView.contentSize.height; } } #pragma mark Scrollview Delegates +- (BOOL)contentHeightLargerThanFrameForScrollView:(UIScrollView *)scrollView +{ + return scrollView.contentSize.height > CGRectGetHeight(scrollView.frame); +} + - (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate { if (!self.isLoading) { - //Calculate scrollable height - CGFloat contentHeight = scrollView.contentSize.height; - CGFloat scrollableHeight = contentHeight - scrollView.bounds.size.height; - - if (scrollView.contentOffset.y > (scrollableHeight + self.triggerDistance) && self.downAction) { - - UIEdgeInsets newInsets = self.orginalInsets; - newInsets.bottom += self.footerView.frame.size.height; - - [self triggerAction:self.downAction forAccessoryView:self.footerView withInsets:newInsets]; - } - - CGFloat topOffset = scrollView.contentOffset.y - scrollView.contentInset.top; - if (topOffset < (-self.triggerDistance) && self.upAction) { - - UIEdgeInsets newInsets = self.orginalInsets; - newInsets.top += self.headerView.frame.size.height; - - [self triggerAction:self.upAction forAccessoryView:self.headerView withInsets:newInsets]; + CGFloat distanceBelowBottomOfScreen = scrollView.contentSize.height - CGRectGetMaxY(scrollView.bounds); + CGFloat distanceAboveTopOfScreen = CGRectGetMinY(scrollView.bounds); + + //Action for getting to bottom + if ([self contentHeightLargerThanFrameForScrollView:scrollView] + && distanceBelowBottomOfScreen <= self.triggerDistance + && self.downAction) { + CGFloat contentHeight = scrollView.contentSize.height; + CGFloat offsetHeight = contentHeight - CGRectGetHeight(self.tableView.frame) - CGRectGetHeight(self.footerView.frame); + CGPoint offset = CGPointMake(0, offsetHeight); + UIEdgeInsets insets = self.tableView.contentInset; + insets.bottom += DefaultAccessoryHeight; + + [self triggerAction:self.downAction + forAccessoryView:self.footerView + withContentOffset:offset + returningToOffset:offset + temporaryInsets:insets]; + } else if (distanceAboveTopOfScreen < (-self.triggerDistance) && self.upAction) { + //Action for pulling down from top. + CGPoint offset = CGPointMake(0, CGRectGetHeight(self.headerView.frame)); + UIEdgeInsets insets = self.tableView.contentInset; + insets.top += DefaultAccessoryHeight; + + [self triggerAction:self.upAction + forAccessoryView:self.headerView + withContentOffset:CGPointZero + returningToOffset:offset + temporaryInsets:insets]; } } } @@ -133,21 +209,18 @@ - (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL - (void)scrollViewDidScroll:(UIScrollView *)scrollView { if (!self.isLoading) { - //Calculate scrollable height - CGFloat contentHeight = scrollView.contentSize.height; - CGFloat scrollableHeight = contentHeight - scrollView.bounds.size.height; - - CGFloat topOffset = scrollView.contentOffset.y + scrollView.contentInset.top; - - if (topOffset > scrollableHeight) { - CGFloat distanceOverscrolled = topOffset - scrollableHeight; - [self.footerView hasOverScrolled:(distanceOverscrolled/self.triggerDistance)]; + CGFloat distanceBelowBottomOfScreen = scrollView.contentSize.height - CGRectGetMaxY(scrollView.bounds); + CGFloat distanceAboveTopOfScreen = CGRectGetMinY(scrollView.bounds); + + if (distanceBelowBottomOfScreen < 0 + && [self contentHeightLargerThanFrameForScrollView:scrollView]) { + [self.footerView hasOverScrolled:(fabs(distanceBelowBottomOfScreen)/self.triggerDistance)]; } else { [self.footerView hasOverScrolled:0.0]; } - - if (topOffset < 0) { - [self.headerView hasOverScrolled:(fabs(topOffset)/self.triggerDistance)]; + + if (distanceAboveTopOfScreen < 0) { + [self.headerView hasOverScrolled:(fabs(distanceAboveTopOfScreen)/self.triggerDistance)]; } else { [self.headerView hasOverScrolled:0.0]; } @@ -158,27 +231,36 @@ - (void)scrollViewDidScroll:(UIScrollView *)scrollView - (void)triggerAction:(VOKPagingResultsAction)action forAccessoryView:(UIView *)accessory - withInsets:(UIEdgeInsets)insets + withContentOffset:(CGPoint)contentOffset + returningToOffset:(CGPoint)returnOffset + temporaryInsets:(UIEdgeInsets)tempInsets { self.isLoading = YES; [self.tableView setUserInteractionEnabled:NO]; - + + UIEdgeInsets originalInsets = self.tableView.contentInset; [accessory loadingWillBegin]; - - [UIView animateWithDuration:.3 animations:^{ - [self.tableView setContentInset:insets]; - } completion:^(BOOL finished) { - VOKCompletionAction completionAction = ^void (void) - { - self.isLoading = NO; - [accessory loadingHasFinished]; - - [self.tableView setUserInteractionEnabled:YES]; - [self.tableView setContentInset:self.orginalInsets]; - }; - - action(self.tableView, completionAction); - }]; + + //self.table is a weak relationship, causing it to be dealloc'd before self while this block was in-flight. + typeof(self.tableView) __strong strongTableView = self.tableView; + [UIView animateWithDuration:.3 + animations:^{ + strongTableView.contentInset = tempInsets; + [strongTableView setContentOffset:contentOffset]; + } + completion:^(BOOL finished) { + VOKCompletionAction completionAction = ^void (void) + { + self.isLoading = NO; + [accessory loadingHasFinished]; + + [strongTableView setUserInteractionEnabled:YES]; + strongTableView.contentInset = originalInsets; + [strongTableView setContentOffset:returnOffset animated:YES]; + }; + + action(strongTableView, completionAction); + }]; } - (void)dealloc From 52cf4eec92dc465cf6a14e32dbf3fc9d721c473c Mon Sep 17 00:00:00 2001 From: Brock Boland Date: Tue, 22 Nov 2016 12:55:06 -0600 Subject: [PATCH 2/5] Clearer CGRect --- Pod/Classes/Optional Data Sources/VOKDefaultPagingAccessory.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Pod/Classes/Optional Data Sources/VOKDefaultPagingAccessory.m b/Pod/Classes/Optional Data Sources/VOKDefaultPagingAccessory.m index 5e7be5b..d753789 100755 --- a/Pod/Classes/Optional Data Sources/VOKDefaultPagingAccessory.m +++ b/Pod/Classes/Optional Data Sources/VOKDefaultPagingAccessory.m @@ -22,7 +22,7 @@ - (void)didMoveToSuperview self.clipsToBounds = YES; [self setBackgroundColor:[UIColor clearColor]]; - UILabel *label = [[UILabel alloc] initWithFrame:(CGRect){CGPointZero, self.frame.size}]; + UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, self.frame.size.width, self.frame.size.height)]; [label setText:@"Pull To Load"]; [label setFont:[UIFont boldSystemFontOfSize:20]]; [label sizeToFit]; From 3e5d2b4f6750ee5857ce5b1f8504539109213aeb Mon Sep 17 00:00:00 2001 From: Brock Boland Date: Tue, 22 Nov 2016 12:55:21 -0600 Subject: [PATCH 3/5] Use correct keypath macro --- .../VOKPagingFetchedResultsDataSource.m | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Pod/Classes/Optional Data Sources/VOKPagingFetchedResultsDataSource.m b/Pod/Classes/Optional Data Sources/VOKPagingFetchedResultsDataSource.m index 9106d8e..50de7ac 100755 --- a/Pod/Classes/Optional Data Sources/VOKPagingFetchedResultsDataSource.m +++ b/Pod/Classes/Optional Data Sources/VOKPagingFetchedResultsDataSource.m @@ -134,7 +134,7 @@ - (void)setupAccessoryViews self.tableView.contentInset = insets; [self.tableView addObserver:self - forKeyPath:VOKKeyForInstanceOf(UITableView, contentSize) + forKeyPath:VOKKeyForObject(self.tableView, contentSize) options:0 // Don't use the old or new value from the dictionary in the method, so pass 0 context:NULL]; } @@ -158,7 +158,7 @@ - (void)observeValueForKeyPath:(NSString *)keyPath change:(NSDictionary *)change context:(void *)context { - if ([keyPath isEqualToString:VOKKeyForInstanceOf(UITableView, contentSize)]) { + if ([keyPath isEqualToString:VOKKeyForObject(self.tableView, contentSize)]) { self.bottomConstraint.constant = self.tableView.contentSize.height; } } @@ -265,7 +265,7 @@ - (void)triggerAction:(VOKPagingResultsAction)action - (void)dealloc { - [self.tableView removeObserver:self forKeyPath:VOKKeyForInstanceOf(UITableView, contentSize)]; + [self.tableView removeObserver:self forKeyPath:VOKKeyForObject(self.tableView, contentSize)]; } @end From 383358aeaf696f5a44a399e2b2a0a4e302b0363c Mon Sep 17 00:00:00 2001 From: Brock Boland Date: Tue, 22 Nov 2016 17:02:21 -0600 Subject: [PATCH 4/5] Tidy up some paging accessory layout --- .../VOKDefaultPagingAccessory.m | 16 ++++++++++++++++ .../VOKPagingFetchedResultsDataSource.m | 16 ++++++++-------- 2 files changed, 24 insertions(+), 8 deletions(-) diff --git a/Pod/Classes/Optional Data Sources/VOKDefaultPagingAccessory.m b/Pod/Classes/Optional Data Sources/VOKDefaultPagingAccessory.m index d753789..2359ecc 100755 --- a/Pod/Classes/Optional Data Sources/VOKDefaultPagingAccessory.m +++ b/Pod/Classes/Optional Data Sources/VOKDefaultPagingAccessory.m @@ -109,6 +109,22 @@ - (void)didMoveToSuperview attribute:NSLayoutAttributeCenterX multiplier:1 constant:0]]; + + // Don't go too wide + [self addConstraint:[NSLayoutConstraint constraintWithItem:containerView + attribute:NSLayoutAttributeLeading + relatedBy:NSLayoutRelationGreaterThanOrEqual + toItem:self + attribute:NSLayoutAttributeLeading + multiplier:1 + constant:0]]; + [self addConstraint:[NSLayoutConstraint constraintWithItem:containerView + attribute:NSLayoutAttributeTrailing + relatedBy:NSLayoutRelationLessThanOrEqual + toItem:self + attribute:NSLayoutAttributeTrailing + multiplier:1 + constant:0]]; } } diff --git a/Pod/Classes/Optional Data Sources/VOKPagingFetchedResultsDataSource.m b/Pod/Classes/Optional Data Sources/VOKPagingFetchedResultsDataSource.m index 50de7ac..dbec161 100755 --- a/Pod/Classes/Optional Data Sources/VOKPagingFetchedResultsDataSource.m +++ b/Pod/Classes/Optional Data Sources/VOKPagingFetchedResultsDataSource.m @@ -61,7 +61,7 @@ - (void)setupAccessoryViews attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:nil - attribute:0 + attribute:NSLayoutAttributeNotAnAttribute multiplier:1 constant:DefaultAccessoryHeight]]; } @@ -90,9 +90,6 @@ - (void)setupAccessoryViews multiplier:1 constant:0]]; - UIEdgeInsets insets = self.tableView.contentInset; - insets.top -= DefaultAccessoryHeight; - if (!self.footerView) { self.footerView = [[VOKDefaultPagingAccessory alloc] init]; self.footerView.translatesAutoresizingMaskIntoConstraints = NO; @@ -100,7 +97,7 @@ - (void)setupAccessoryViews attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:nil - attribute:0 + attribute:NSLayoutAttributeNotAnAttribute multiplier:1 constant:DefaultAccessoryHeight]]; } @@ -130,6 +127,9 @@ - (void)setupAccessoryViews constant:self.tableView.contentSize.height]; [self.tableView addConstraint:self.bottomConstraint]; + // Adjust the insets to push the paging accessory views off-screen initially + UIEdgeInsets insets = self.tableView.contentInset; + insets.top -= DefaultAccessoryHeight; insets.bottom -= DefaultAccessoryHeight; self.tableView.contentInset = insets; @@ -185,7 +185,7 @@ - (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL CGPoint offset = CGPointMake(0, offsetHeight); UIEdgeInsets insets = self.tableView.contentInset; insets.bottom += DefaultAccessoryHeight; - + [self triggerAction:self.downAction forAccessoryView:self.footerView withContentOffset:offset @@ -214,13 +214,13 @@ - (void)scrollViewDidScroll:(UIScrollView *)scrollView if (distanceBelowBottomOfScreen < 0 && [self contentHeightLargerThanFrameForScrollView:scrollView]) { - [self.footerView hasOverScrolled:(fabs(distanceBelowBottomOfScreen)/self.triggerDistance)]; + [self.footerView hasOverScrolled:(fabs(distanceBelowBottomOfScreen) / self.triggerDistance)]; } else { [self.footerView hasOverScrolled:0.0]; } if (distanceAboveTopOfScreen < 0) { - [self.headerView hasOverScrolled:(fabs(distanceAboveTopOfScreen)/self.triggerDistance)]; + [self.headerView hasOverScrolled:(fabs(distanceAboveTopOfScreen) / self.triggerDistance)]; } else { [self.headerView hasOverScrolled:0.0]; } From 0224bf7f228c22f87fd663b999dd6205a04877a8 Mon Sep 17 00:00:00 2001 From: Brock Boland Date: Tue, 22 Nov 2016 17:05:58 -0600 Subject: [PATCH 5/5] Inline completion block --- .../VOKPagingFetchedResultsDataSource.m | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/Pod/Classes/Optional Data Sources/VOKPagingFetchedResultsDataSource.m b/Pod/Classes/Optional Data Sources/VOKPagingFetchedResultsDataSource.m index dbec161..aabf44f 100755 --- a/Pod/Classes/Optional Data Sources/VOKPagingFetchedResultsDataSource.m +++ b/Pod/Classes/Optional Data Sources/VOKPagingFetchedResultsDataSource.m @@ -246,20 +246,17 @@ - (void)triggerAction:(VOKPagingResultsAction)action [UIView animateWithDuration:.3 animations:^{ strongTableView.contentInset = tempInsets; - [strongTableView setContentOffset:contentOffset]; + strongTableView.contentOffset = contentOffset; } completion:^(BOOL finished) { - VOKCompletionAction completionAction = ^void (void) - { + action(strongTableView, ^(void) { self.isLoading = NO; [accessory loadingHasFinished]; - - [strongTableView setUserInteractionEnabled:YES]; + + strongTableView.userInteractionEnabled = YES; strongTableView.contentInset = originalInsets; [strongTableView setContentOffset:returnOffset animated:YES]; - }; - - action(strongTableView, completionAction); + }); }]; }