Sticky UITableViewController section header reveals cells below

In my UITableViewController when a sticky section header is replaced by the following header in succession, the cell below is revealed for a short time. This looks like a glitch to me. Is there a workaround to solve this?

The issue is best explained in video: https://youtube.com/shorts/JIEbFTTIDjA?feature=share

I solved it using this workaround:

override func scrollViewDidScroll(_ scrollView: UIScrollView) {
    guard let tableView = scrollView as? UITableView else { return }
    for cell in tableView.visibleCells {
        let rect = tableView.convert(cell.frame, to: tableView)
        if rect.origin.y <= tableView.contentOffset.y {
            cell.isHidden = true
        } else {
            cell.isHidden = false
        }
    }
}
Sticky UITableViewController section header reveals cells below
 
 
Q