将一行添加到表后,我使用scrollToRowAtIndexPath将该行定位在屏幕中间,然后依靠scrollViewDidEndScrollingAnimation突出显示同一行。
有时,该行无法滚动;例如,当它是表中第一个时。在这些情况下,不会调用scrollViewDidEndScrollingAnimation,因此不会高亮显示新添加的行。
有没有办法知道scrollToRowAtIndexPath是否会对表产生任何影响?
插入时,您必须指定要插入的indexPaths,对吗?公开存储这些indexPaths,并在CellForRowAtIndexPath中以高亮颜色重新加载该行,或者单独重新加载行。
例如:将插入行的索引路径添加到公共数组。
[tableView insertRowsAtIndexPaths:indexpathArray withRowAnimation:UITableViewRowAnimationFade];
self.colorIndexs = indexpathArray;
然后将其添加到cellForRowAtIndexPath 中
if ([colorIndexs count] > 0 && [colorIndexs containsObject:indexPath])
customCell.contentView.backgroundColor = [UIColor redColor];