2011-04-22 37 views
1

行号当我使用获得在scrollViewDidEndDecelerating

- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView{ 
    NSArray *visibleCells = [my_table visibleCells]; 

我想知道行(MY_TABLE)的数量是可见的(与visibleCells)。

例如,如果我做

[visibleCells count]; 

我知道有5行可见的,但我需要知道的实数(例如:在3号,4,5,6,7表视图)。

可能吗?

回答

0

您可以在数组的第一个和最后一个对象的表视图上调用indexPathForCell:以获取两个索引路径。

+0

感谢你,但是......我怎么能叫indexPathForCell:对于一个特定的细胞?以及我如何sei NSIndexPath? – JAA 2011-04-22 18:22:33

0

解决了!

使用该

UITableViewCell *currentCell = [visibleCells objectAtIndex:i]; 
NSIndexPath *indexPath = [tabella_gallery indexPathForCell:currentCell]; 

工作正常!

0

这里有一个方法我用

func loadImagesForVisibleRows() { 

    // Get the visible cells indexPaths 
    let indexes: Array = tableView.indexPathsForVisibleRows()! 

    // Loop through them to determine whether visible or not 
    for index in indexes { 

     let row = index.row 
     // Do what you need to do 

    } 
}