如何在swift中获取两个UICollectionView的ScrollView?
正如我使用此代码在pageControl中获取当前页面索引一样。但此函数无法区分scrollView是否用于哪个collectionView。如何在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.
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
}
}