How To Get Current Shown Collectionview Cell Index In Swift

[Solved] How To Get Current Shown Collectionview Cell Index In Swift | Swift - Code Explorer | yomemimo.com
Question : how to get current shown collectionview cell index in swift

Answered by : mobile-star

let visibleRect = CGRect(origin: collectionView.contentOffset, size: collectionView.bounds.size)
let visiblePoint = CGPoint(x: visibleRect.midX, y: visibleRect.midY)
let visibleIndexPath = collectionView.indexPathForItem(at: visiblePoint)

Source : | Last Update : Tue, 31 Mar 20

Question : how to get current shown collectionview cell index in swift

Answered by : mobile-star

func scrollViewDidEndDecelerating(_ scrollView: UIScrollView) { for cell in yourCollectionView.visibleCells { let indexPath = yourCollectionView.indexPath(for: cell) print(indexPath) }
}

Source : | Last Update : Tue, 31 Mar 20

Answers related to how to get current shown collectionview cell index in swift

Code Explorer Popular Question For Swift