I am getting a index of data as int. I m getting position of my data which can be 1 or 2 or 3 or 4 .. so on. How can i use these int to fetch colletionviewcell from collectionview.
on each scrolling i m getting index of cell as int for e.g initally it will be 0 for next swipe the number will be 1, next swipe nos will be 2 and so on.
func scrollViewWillEndDragging(_ scrollView: UIScrollView, withVelocity velocity: CGPoint, targetContentOffset: UnsafeMutablePointer<CGPoint>) {
let layout = self.collectionView.collectionViewLayout as! UICollectionViewFlowLayout
let cellWidthIncludingSpacing = layout.itemSize.width + layout.minimumLineSpacing
var offset = targetContentOffset.pointee
let index = (offset.x + scrollView.contentInset.left) / cellWidthIncludingSpacing
let roundIndex = round(index)
offset = CGPoint(x: roundIndex * cellWidthIncludingSpacing - scrollView.contentInset.left, y: -scrollView.contentInset.top)
targetContentOffset.pointee = offset
for cell in collectionView.visibleCells as! [CaurosalCollectionViewCell] {
// do something
print(cell.title.text)
}
}