When I check for a table's visible indexPaths with 'indexPathsForVisibleRows
' during UIScrollViewDelegate's scrollViewDidScroll and scrollViewDidEndDragging
, it seems to be accurate.
But sometimes just when scrolling and dragging is ending and 'cellForRowAtIndexPath
' is invoked, the call to 'indexPathsForVisibleRows
' returns 0. There are rows visible on-screen so I know it can't be 0. As soon as this happens, I can invoke UITableView::visibleCells
and get a non-zero value.
Why does this discrepancy exist?
Best Answer
Did you tried calling methods in below sequence:
There is a bug in iOS with indexPathsForVisibleRows. Use above two line code to get correct visible rows.