Scroll all rows of a UICollectionView at the same time

377 Views Asked by At

On my Controller, I have a UICollectionView and I am loading data in 3 sections. These rows are showing price object. Each UICollectionViewCell contains class types like UILabel, TextField, and Checkbox. My requirement is if a user scrolls 1 row then all rows of the section should scroll at the same. For ex, there are 4 rows in section 0 and user scrolls 1st row then all 4 rows should scroll in the same direction.

If I have multiple UICollectionView in my class then I can handle the scroll using below code

self.priceCollectionView.contentOffset = scrollView.contentOffset

But here I have 1 UICollectionView so I tried below code

func scrollViewDidScroll(_ scrollView: UIScrollView) {
    let rowCount = self.priceCollectionView.numberOfItems(inSection: 0)
    for i in 0..<rowCount {
        let item = self.priceCollectionView.cellForItem(at: IndexPath(item: i, section: 0))

    }
}

Refer Image to see the cell data

These are the rows which I have to scroll simultaneously

I also followed below link

But there is no item.contentOffset property available. How should I solve this issue? Thanks in advance!!!

0

There are 0 best solutions below