【发布时间】:2015-03-11 21:21:49
【问题描述】:
我正在尝试从 tableview 重新加载特定行,但 tableview 的 contentOffset 在重新加载后重置为 (0, 0)。我尝试在 reloadRowsAtIndexPaths 周围添加 [tableview beginUpdates] 和 [tableview endUpdates] 但没有改变行为。
在Calling reloadRowsAtIndexPaths removes tableView contentOffset这里提出了这个问题,但并没有解决问题。我很确定动画与这种行为无关。我不确定如何在重新加载 tableview 行的同时维护 tableview 的内容偏移量。
[tableView reloadRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationAutomatic];
【问题讨论】:
-
这个功能你试过了吗:scrollToRowAtIndexPath:atScrollPosition:animated after reloading the row?
-
是的,我试过
scrollToRowAtIndexPath:atScrollPosition:animated,但没用。我尝试在重新加载行后设置 contentOffset,但 tableview 会跳转偏移量,这不是我想要的行为。我不希望在重新加载该 tableview 中的一行时更改 tableview 内容偏移量。 -
有人对这个问题有意见吗?我仍在试图弄清楚如何解决这个问题,并且没有太多关于它的信息。
-
看这个例子:photocity.googlecode.com/svn/trunk/PhotoCity_iPhone/co/… 这几乎就是你正在做的......它调用 [self setContentOffset:contentOffset animated:NO];
-
此外,调用 deleteRowsAtIndexPaths 或 insertRowsAtIndexPath 时应调用 [tableview beginUpdates] 和 [tableview endUpdates],而不是使用 reloadRowsAtIndexPaths。希望对您有所帮助。
标签: ios objective-c uitableview reloaddata contentoffset