Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/wix/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 如何在scrollViewDidScroll中获取对collectionView标题的引用?_Ios_Swift_Uicollectionview - Fatal编程技术网

Ios 如何在scrollViewDidScroll中获取对collectionView标题的引用?

Ios 如何在scrollViewDidScroll中获取对collectionView标题的引用?,ios,swift,uicollectionview,Ios,Swift,Uicollectionview,我正在实现collectionView的scollViewDidScroll委托方法,我需要获取对我的头的引用,以便访问header.swift文件中的一些出口 func collectionView(_ collectionView: UICollectionView, viewForSupplementaryElementOfKind kind: String, at indexPath: IndexPath) -> UICollectionReusableView {

我正在实现collectionView的scollViewDidScroll委托方法,我需要获取对我的头的引用,以便访问header.swift文件中的一些出口

func collectionView(_ collectionView: UICollectionView, viewForSupplementaryElementOfKind kind: String, at indexPath: IndexPath) -> UICollectionReusableView {
           let header = collectionView.dequeueReusableSupplementaryView(ofKind: kind, withReuseIdentifier: headerID, for: indexPath) as! publicEventsHeader
        header.headerImage.image = UIImage(named: "stadium", in: nil, with: nil)
        header.collectionView.delegate = header
        header.collectionView.dataSource = header
           return header
       }

那么,如何在scrollViewDidScroll方法中访问此委托方法的标题呢?

使用
collectionView
方法的
VisibleSupplementaryView(ofKind:)
来获取所有当前可见的headerViews

func scrollViewDidScroll(_ scrollView: UIScrollView) {
    if let headersViews = (scrollView as? UICollectionView)?.visibleSupplementaryViews(ofKind: UICollectionElementKindSectionHeader) {
        //add your code here...
    }
}