有时候需要根据tag来获取cell,需要创建NSIndexpath,我们可能会这么用:
NSIndexPath *indexPath = [[NSIndexPath alloc] initWithIndex:tag];
没有报错,但很遗憾的是通过这样的indexPath,你是怎么都获取不到cell的!正确的创建方法是:
NSIndexPath *indexPath = [NSIndexPath indexPathForRow:row inSection:section];
本文介绍了如何正确地使用NSIndexPath来获取cell。特别指出,直接使用tag创建NSIndexPath的方法是错误的,并提供了正确的创建NSIndexPath的方法。
有时候需要根据tag来获取cell,需要创建NSIndexpath,我们可能会这么用:
NSIndexPath *indexPath = [[NSIndexPath alloc] initWithIndex:tag];
没有报错,但很遗憾的是通过这样的indexPath,你是怎么都获取不到cell的!正确的创建方法是:
NSIndexPath *indexPath = [NSIndexPath indexPathForRow:row inSection:section];

被折叠的 条评论
为什么被折叠?