补充视图的节号是多少?



我正在使用UICollectionViewController.在某些时候,需要对可见页脚进行一些配置,对于它们中的每一个,我需要知道它的当前节号。当前,因为部分可能会被替换,并且可重用视图的部分可能会更改。

self.collectionView.visibleSupplementaryViews(ofKind: UICollectionView.elementKindSectionFooter)
.filter { $0.reuseIdentifier == reuseIdentifierFooter}
.forEach {
// Here I need to know the section number of each view
}

获取可见视图的索引路径:https://developer.apple.com/documentation/uikit/uicollectionview/1618034-indexpathsforvisiblesupplementar

然后循环访问索引路径并使用 https://developer.apple.com/documentation/uikit/uicollectionview/1618041-supplementaryview 查询视图

最新更新