Determine if a tablecell is really seen by user in tableview

Hi folks,

I'm trying to find a way to check if several of my table cells are really being seen by users (let's say, if the cell is at least 1px shown, I consider it as being seen). And also need to make sure if users scroll up and down, I'll need to trigger the method. (This should be easy as I can put the check in listener method like DidScroll or something)

Seems like using indexPathsForVisibleRows can only give me rows that are almost 100% visible in the screen.

I'm searching for solutions, and looks like using rectForRowAtIndexPath and doing some math with contentOffset may give me what I want. Not sure if there's better way.

Anyone could help? Thanks very much!

Depending on where you are coming from I see two options for this. If you want to check this for all cells, you can iterate over the visibleCells array of the table view and compare the cell's frame to the bounds of the table view (make sure to convert to the correct coordinate space). If you want to check this only for specific cells, you can also just ask for cellForRowAtIndexPath: and then check the frame of that particular cell. Whatever you do, if you put this in scrollViewDidScroll make sure to make this really fast cause this will be called while scrolling on every bounds origin change.

If you don't care too much about how much of a cell is visible, it might also be good enough to simply monitor the delegate callbacks tableView:willDisplayCell:forRowAtIndexPath: and tableView:didEndDisplayingCell:forRowAtIndexPath:.

Determine if a tablecell is really seen by user in tableview
 
 
Q