向表中添加一行后,我使用scrollToRowAtIndexPath将该行定位在屏幕中间,然后依靠scrollViewDidEndScrollingAnimation突出显示同一行。
有时,行不能滚动;例如,当它是表中的第一个时。在这些情况下,不会调用scrollViewDidEndScrollingAnimation,因此不会突出显示新添加的行。
有没有办法知道scrollToRowAtIndexPath是否会对表格产生任何影响?
向表中添加一行后,我使用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];