UITableView indexPathsForVisibleRows
- (NSArray *)indexPathsForVisibleRows
Return Value of [UITableView indexPathsForVisibleRows]
An array of NSIndexPath objects each representing a row index and section index that together identify a visible row in the table view. Returns nil if no rows are visible.
UITableView indexPathsForVisibleRows example.
Did you tried calling methods in below sequence:
[MyTable visibleCells];
[MyTable indexPathsForVisibleRows];
There is a bug in iOS with indexPathsForVisibleRows. Use above two line code to get correct visible rows.
[MyTable visibleCells];
[MyTable indexPathsForVisibleRows];
There is a bug in iOS with indexPathsForVisibleRows. Use above two line code to get correct visible rows.
Example of [UITableView indexPathsForVisibleRows].
-(BOOL)isRowZeroVisible {
NSArray *indexes = [tableView indexPathsForVisibleRows];
for (NSIndexPath *index in indexes) {
if (index.row == 0) {
return YES;
}
}
return NO;
}
NSArray *indexes = [tableView indexPathsForVisibleRows];
for (NSIndexPath *index in indexes) {
if (index.row == 0) {
return YES;
}
}
return NO;
}
UITableView indexPathsForVisibleRows example.
- (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate{
NSIndexPath *firstVisibleIndexPath = [[self.tableView indexPathsForVisibleRows] objectAtIndex:0];
NSLog(@"first visible cell's section: %i, row: %i", firstVisibleIndexPath.section, firstVisibleIndexPath.row);
}
NSIndexPath *firstVisibleIndexPath = [[self.tableView indexPathsForVisibleRows] objectAtIndex:0];
NSLog(@"first visible cell's section: %i, row: %i", firstVisibleIndexPath.section, firstVisibleIndexPath.row);
}