UICollectionView current visible cell index

后端 未结 16 1473
难免孤独
难免孤独 2020-11-29 16:52

I am using UICollectionView first time in my iPad application. I have set UICollectionView such that its size and cell size is same, means only onc

16条回答
  •  广开言路
    2020-11-29 17:16

    Swift 3.0

    Simplest solution which will give you indexPath for visible cells..

    yourCollectionView.indexPathsForVisibleItems 
    

    will return the array of indexpath.

    Just take the first object from array like this.

    yourCollectionView.indexPathsForVisibleItems.first
    

    I guess it should work fine with Objective - C as well.

提交回复
热议问题