繁体   English   中英

如何重新加载UITableview中的特定部分?

[英]How reload particular section in UITableview?

当我尝试重新加载特定的部分时,表格视图会自动向上方滚动,而我不明白发生了什么?我使用了下面的代码。

        [_moviesDetailTableview beginUpdates];
        [_moviesDetailTableview reloadSections:[NSIndexSet indexSetWithIndex:1]withRowAnimation:UITableViewRowAnimationNone];
        [_moviesDetailTableview endUpdates];

并且您可以存储表视图的content offset 并可以做类似的事情,

 GPoint contentOffset = _moviesDetailTableview.contentOffset;
 [_moviesDetailTableview beginUpdates];
 [_moviesDetailTableview reloadSections:[NSIndexSet indexSetWithIndex:1]withRowAnimation:UITableViewRowAnimationNone];
 [_moviesDetailTableview endUpdates];
 [_moviesDetailTableview layoutIfNeeded];
 [_moviesDetailTableview setContentOffset:contentOffset];

试试这个代码,

[self.tableView reloadSection:0 withRowAnimation:UITableViewRowAnimationNone];

- (void) reloadSection:(NSInteger)section withRowAnimation:(UITableViewRowAnimation)rowAnimation {
    NSRange range = NSMakeRange(section, 1);
    NSIndexSet *sectionToReload = [NSIndexSet indexSetWithIndexesInRange:range];                                     
    [self reloadSections:sectionToReload withRowAnimation:rowAnimation];
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM