UITableView - Get the topmost hovered Section

My initial idea was similar to this article . The general idea is to display the group header. The UITableView proxy method that will display the group header determines which group header is the top layer. The idea is not wrong, but I tried it out. In Between two groups switching. There will be bugs when sliding up and down without letting go (specifically, the current display group header is always +1, +1, +1).

{   
    //使用currentTopSectionViewCount记录当前显示的最上层的Section.在控制器中初始化为0.
    long _currentTopSectionViewCount;
}

The main thing is all the UIScrollView and the scrolled delegates that inherit from the UISCrollView child controls. And the
currently displayed "Cells". - (UITableViewCell *)visibleCells;Called by.

- (void)scrollViewDidScroll:(UIScrollView *)scrollView{
    if (scrollView == self.tableView) {
        NSArray <ZGAccountsBookDataTableViewCell *> *cellArray = [self.tableView  visibleCells];
        //cell的section的最小值
        long cellSectionMINCount = LONG_MAX;
        for (int i = 0; i < cellArray.count; i++) {
            ZGAccountsBookDataTableViewCell *cell = cellArray[i];
            long cellSection = [self.tableView indexPathForCell:cell].section;
            if (cellSection < cellSectionMINCount) {
                cellSectionMINCount = cellSection;
            }
        }
        _currentTopSectionViewCount = cellSectionMINCount;
        NSLog(@"当前悬停的组头是:%ld",_currentTopSectionViewCount);
    }
}

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324884950&siteId=291194637