2011-04-22 14 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 

    } 
}