Check whether cell at indexPath is visible on screen UICollectionView
Nested UICollectionViews need oft to not scroll at all, so that no contentOffset is ever provided and thus iOS understands all cells as being always visible. In that case it is possible to take the screen boundaries as reference:
let cellRect = cell.contentView.convert(cell.contentView.bounds, to: UIScreen.main.coordinateSpace)
if UIScreen.main.bounds.intersects(cellRect) {
print("cell is visible")
}
Get current available cells
// get visible cells
let visibleIndexPaths = followedCollectionView.indexPathsForVisibleItems
Then check if your indexPath
is contained in the visibleIndexPaths
array or not, before doing anything with cells.