【发布时间】:2015-05-01 22:54:05
【问题描述】:
编辑:
我找到了这个 SO 线程。
UITableView inserting section at top while scrolling
- 我有一个tableView
- 我最初加载了 5 个部分
- 然后我向上滚动,当显示第 0 节和第 0 行时,我加载接下来的 5 节并使用 插入表格视图
[self beginUpdates]; [self deleteSections:[NSIndexSet indexSetWithIndex:0] withRowAnimation:UITableViewRowAnimationNone]; [self insertSections:[NSIndexSet indexSetWithIndex:0] withRowAnimation:UITableViewRowAnimationNone]; [self insertSections:[NSIndexSet indexSetWithIndex:1] withRowAnimation:UITableViewRowAnimationNone]; [self insertSections:[NSIndexSet indexSetWithIndex:2] withRowAnimation:UITableViewRowAnimationNone]; [self endUpdates];
但是我的问题是 tableView 在插入后在第 0 节和第 0 行获得位置
但我想定位在插入的最后一个新部分的最后一行(即上面代码中的第 2 部分)
我在开始/结束更新内外都试过这个
NSIndexPath *indexPath = [NSIndexPath indexPathForRow:0 inSection:2];
[self scrollToRowAtIndexPath:indexPath
atScrollPosition:UITableViewScrollPositionBottom animated:YES];
但它会突然发生。
【问题讨论】:
-
[self scrollToRowAtIndexPath:indexPath atScrollPosition:UITableViewScrollPositionBottom Animation:NO];为什么动画属性是“NO”?
-
我尝试了“是”和“否”...我刚刚在问题中发布了“否”
-
你可以尝试用延迟“0.4”滚动,看看它做了什么。制作“withRowAnimation:UITableViewRowAnimationFade”。
-
@user2384694 你继承了表格视图吗?
-
@user2384694 你在使用 UITbleViewController 吗?
标签: ios objective-c uitableview