首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >indexPath和indexPath.row的区别(iphone)

indexPath和indexPath.row的区别(iphone)
EN

Stack Overflow用户
提问于 2011-08-20 22:24:31
回答 1查看 1.8K关注 0票数 2

我搞混了indexPath和indexPath.row,tableView的每个单元都对应一个indexPath吗?那么为什么我们要寻找这个indexPath的“行”呢?我查过医生了,但我想它把我搞糊涂了。

我找到了这段代码:

代码语言:javascript
复制
// this method is used in case the user scrolled into a set of cells that don't have their app icons yet
- (void)loadImagesForOnscreenRows
{
    if ([self.entries count] > 0)
    {
        NSArray *visiblePaths = [self.tableView indexPathsForVisibleRows];
        for (NSIndexPath *indexPath in visiblePaths)
        {
            AppRecord *appRecord = [self.entries objectAtIndex:indexPath.row];

            if (!appRecord.appIcon) // avoid the app icon download if the app already has an icon
            {
                [self startIconDownload:appRecord forIndexPath:indexPath];
            }
        }
    }
}

你能给我解释一下两者之间的区别吗?

非常感谢

保罗

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2011-08-20 22:56:43

NSIndexPath类的每个实例都有两个属性:行和节(Documentation)

tableView的每个单元对应于唯一的indexPath (第M部分中的第N行)。通常只有一个部分,人们只使用row来引用数据。

票数 4
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/7132352

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档