简体   繁体   English

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

[英]How reload particular section in UITableview?

When I tried to reload particular section table view scrolls in top direction automatically and I can't understand what is happening?And I used this below code.When I tap on any button full table view scroll to top direction. 当我尝试重新加载特定的部分时,表格视图会自动向上方滚动,而我不明白发生了什么?我使用了下面的代码。

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

And you can store content offset of your tableview. 并且您可以存储表视图的content offset and can do something like, 并可以做类似的事情,

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

Try this code, 试试这个代码,

[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