Skip to content

Commit

Permalink
fix bug: #36
Browse files Browse the repository at this point in the history
  • Loading branch information
TalkingJourney committed Oct 26, 2019
1 parent 51d50b9 commit c77593c
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions SCIndexView/SCIndexView.m
Original file line number Diff line number Diff line change
Expand Up @@ -165,11 +165,15 @@ - (void)configCurrentSection
}
}

NSInteger firstVisibleSection = self.tableView.indexPathsForVisibleRows.firstObject.section;
CGFloat insetTop = kSCIndexViewInsetTop;
CGPoint contentOffset = self.tableView.contentOffset;
CGPoint point = CGPointMake(contentOffset.x, contentOffset.y + insetTop);
NSIndexPath *indexPath = [self.tableView indexPathForRowAtPoint:point];
currentSection = indexPath.section;
for (NSInteger section = firstVisibleSection; section < self.tableView.numberOfSections; section++) {
CGRect sectionFrame = [self.tableView rectForSection:section];
if (sectionFrame.origin.y + sectionFrame.size.height - self.tableView.contentOffset.y > insetTop) {
currentSection = section;
break;
}
}

BOOL selectSearchLayer = NO;
if (currentSection == 0 && self.searchLayer && currentSection < self.tableView.numberOfSections) {
Expand Down

0 comments on commit c77593c

Please sign in to comment.