try it
On delegate
func scrollViewDidEndDecelerating(scrollView: UIScrollView) { for cell in yourCollectionViewname.visibleCells() as [UICollectionViewCell] { let indexPath = yourCollectionViewname.indexPathForCell(cell as UICollectionViewCell) NSLog("%@", indexPath) } }
Choice-2
at the touch of a button
var point : CGPoint = sender.convertPoint(CGPointZero, toView:yourCollectionViewname) var indexPath =yourCollectionViewname!.indexPathForItemAtPoint(point)
Show all items
you can use indexPathsForVisibleRows
Returns an array of pointer paths, each of which identifies the visible string in the receiver.
- (NSArray *) indexPathsForVisibleItems;
var visible: [AnyObject] = yourCollectionViewname.indexPathsForVisibleItems var indexpath: NSIndexPath = (visible[0] as! NSIndexPath)
Anbu.karthik
source share