【发布时间】:2012-06-14 03:03:58
【问题描述】:
我首先制作了一个包含 5 个部分的 UITableView,每个部分 3 行。第一行是标题,第二行是图片,第三行是页脚,数据来自网络,包含每个单元的标题、图片、页脚。因为数据很大,所以我通过向上拖动UITableView的底部进行分页,通过向下拖动UITableView的顶部进行上一页。它就像 9GAG 阅读器一样工作。我也想在换页的时候给9GAG Reader做同样的动画,动画就是-
.当下一页准备好时,它会滚动到我做的下一页,工作正常。 .下一页完成后,上一页将被删除。
对于每一页,有5个部分,所以我是这样做的-我先在页面添加5个部分,如果转到下一页,将再添加5个部分,然后滚动到第5个部分,所以滚动动画效果很好。
但是对于下一部分,我删除了 0-4 个部分后,其余部分的位置发生了变化,这是一个问题。我想固定下一页的位置,我该怎么做?
// here expend to 2 page, 10 sections, and then scroll to the next page
self.totalSections = TOTAL_SECTIONS * 2;
[self.mainContent reloadData];
[self.mainContent scrollToRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:TOTAL_SECTIONS] atScrollPosition:UITableViewScrollPositionTop animated:YES];
// here delete the 0-5 sections, the previous page, but postion is changed..
NSIndexSet *deletes = [NSIndexSet indexSetWithIndexesInRange:NSMakeRange(0, 5)];
self.totalSections = TOTAL_SECTIONS;
[self.mainContent deleteSections:deletes withRowAnimation:UITableViewRowAnimationNone];
【问题讨论】:
标签: iphone ios uitableview animation