Check whether cell at indexPath is visible on screen UICollectionView

后端 未结 4 875
春和景丽
春和景丽 2021-02-19 18:44

I have a CollectionView which displays images to the user. I download these in the background, and when the download is complete I call the following func to update

4条回答
  •  余生分开走
    2021-02-19 19:26

    You can get current index by

    // Called before the cell is displayed    
    func collectionView(_ collectionView: UICollectionView, willDisplay cell: UICollectionViewCell, forItemAt indexPath: IndexPath) {
        print(indexPath.row)
    }
    
    // Called when the cell is displayed
    func collectionView(_ collectionView: UICollectionView, didEndDisplaying cell: UICollectionViewCell, forItemAt indexPath: IndexPath) {
        print(indexPath.row)
    }
    

提交回复
热议问题