is there a way to get all the section header views that are visible?
something similar to UITableView\'s visibleCells instance method..
A UITableView extension that gives you the visibleHeaderViews based on @OhadM answer (https://stackoverflow.com/a/45525595/5058116), but which checks on potential nil values.
extension UITableView {
/// The section header views that are visible in the table view.
var visibleHeaderViews: [UITableViewHeaderFooterView] {
var headerViews = [UITableViewHeaderFooterView]()
guard let indexPaths = indexPathsForVisibleRows else { return headerViews }
for indexPath in indexPaths {
if let headerView = headerView(forSection: indexPath.section) {
headerViews.append(headerView)
}
}
return headerViews
}
}