Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/16.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
如何在swift中获取两个UICollectionView的ScrollView?_Swift_Uicollectionview_Scrollview_Uipagecontrol - Fatal编程技术网

如何在swift中获取两个UICollectionView的ScrollView?

如何在swift中获取两个UICollectionView的ScrollView?,swift,uicollectionview,scrollview,uipagecontrol,Swift,Uicollectionview,Scrollview,Uipagecontrol,正如我使用此代码在pageControl中获取当前页面索引一样。但此函数无法区分scrollView是否用于哪个collectionView。 func scrollViewDidEndDecelerating(_ scrollView: UIScrollView) { if collectionView == self.brandCollectionView { brandPageControl.currentPage = Int(scrollView.

正如我使用此代码在pageControl中获取当前页面索引一样。但此函数无法区分scrollView是否用于哪个collectionView。

func scrollViewDidEndDecelerating(_ scrollView: UIScrollView) {
        if collectionView == self.brandCollectionView {
            brandPageControl.currentPage = Int(scrollView.contentOffset.x) / Int(scrollView.frame.width)
        } else {
            brandPageControl.currentPage = Int(scrollView.contentOffset.x) / Int(scrollView.frame.width)
        }
    }
解决方案正在发挥作用:

func scrollViewDidEndDecelerating(_ scrollView: UIScrollView) {
       if scrollView == self.collectionView {
           //code for this scrollView1
        } else {
             //code for this scrollView2
        }
    }