开发者

Getting row number in scrollViewDidEndDecelerating

when i use

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

i want to know the number of the row (in my_table) that is visible (with visibleCells).

For example, if i do

[v开发者_JAVA技巧isibleCells count];

i know that there are 5 rows visible, but i need to know the real number (for example: number 3, 4, 5, 6, 7 in the table view).

Is it possible?


You can call indexPathForCell: on the table view with the first and last objects of the array to get the two index paths.


solved!

using this

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

works fine!


Here is a method I use

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

    }
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜