how to retrieve all visible table section header views

后端 未结 10 453
渐次进展
渐次进展 2020-12-31 04:44

is there a way to get all the section header views that are visible?

something similar to UITableView\'s visibleCells instance method..

10条回答
  •  傲寒
    傲寒 (楼主)
    2020-12-31 05:15

    I really liked @adamsiton's solution and I ended up translating it to swift. Here it is, FYI.

    I called the file UITableView+VisibleSections.swift

    import UIKit
    
    public extension UITableView {
    
        var indexesOfVisibleSections: [Int] {
            // Note: We can't just use indexPathsForVisibleRows, since it won't return index paths for empty sections.
            var visibleSectionIndexes = [Int]()
    
            for i in 0..

提交回复
热议问题