Reputation: 165
My table view covers part of the view. If I have 20 objects, I am displaying all of them in a tableview. But I want to know that how many cell are loaded that are visible to the user. (i.e. first 5 cells data is visible for me: when I scroll down, the remaining cells will load. Here I want to know without scrolling how many cell are loaded.)
Is this possible?
Upvotes: 6
Views: 8017
Reputation: 523
You can use [tableView visibleCells] count]
, which returns numbers of the table cells that are visible, if I understand correctly what you want.
Upvotes: 15
Reputation: 1965
The below code will give you the array of indexpath of cells currently visible
NSArray *visiblePaths = [self.tableView indexPathsForVisibleRows];
after getting the index path you can easily access the cell at a particular indexpath
Upvotes: 3
Reputation: 20410
Can you take the size of the visible part of the table, and then the size of one cell, and divide them to know how many of them fit in the screen?
Upvotes: 1