我搞混了indexPath和indexPath.row,tableView的每个单元都对应一个indexPath吗?那么为什么我们要寻找这个indexPath的“行”呢?我查过医生了,但我想它把我搞糊涂了。
我找到了这段代码:
// 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];
}
}
}
}你能给我解释一下两者之间的区别吗?
非常感谢
保罗
发布于 2011-08-20 22:56:43
NSIndexPath类的每个实例都有两个属性:行和节(Documentation)
tableView的每个单元对应于唯一的indexPath (第M部分中的第N行)。通常只有一个部分,人们只使用row来引用数据。
https://stackoverflow.com/questions/7132352
复制相似问题