From de611034525528a012e91f75d11c2175d7698b81 Mon Sep 17 00:00:00 2001 From: Giom Foret Date: Tue, 25 Apr 2017 14:57:55 +0200 Subject: [PATCH] Prepare UX rework: - Fix flickering observed on sticky headers when the full table content is displayed --- Riot/ViewController/RecentsViewController.m | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/Riot/ViewController/RecentsViewController.m b/Riot/ViewController/RecentsViewController.m index 44a3d6eaf..bbda4d399 100644 --- a/Riot/ViewController/RecentsViewController.m +++ b/Riot/ViewController/RecentsViewController.m @@ -509,13 +509,22 @@ - (void)refreshStickyHeadersContainersHeight { + // Check whether the full table content is visible. + if (self.recentsTableView.contentSize.height + self.recentsTableView.contentInset.top + self.recentsTableView.contentInset.bottom <= self.recentsTableView.frame.size.height ) + { + // No sticky header is required. Hide them to prevent from flickering in case of vertical bounces. + self.stickyHeadersTopContainerHeightConstraint.constant = 0; + self.stickyHeadersBottomContainerHeightConstraint.constant = 0; + return; + } + if (_enableStickyHeaders) { // Retrieve the first and the last headers actually visible in the recents table view. // Caution: In some cases like the screen rotation, some displayed section headers are temporarily not visible. UIView *firstDisplayedSectionHeader, *lastDisplayedSectionHeader; CGFloat containerHeight; - CGFloat maxVisiblePosY = self.recentsTableView.contentOffset.y + (self.recentsTableView.frame.size.height - self.recentsTableView.contentInset.bottom); + CGFloat maxVisiblePosY = self.recentsTableView.contentOffset.y + self.recentsTableView.frame.size.height - self.recentsTableView.contentInset.bottom; for (UIView *header in displayedSectionHeaders) {