Ios 如何在UITableview中重新加载特定节?

Ios 如何在UITableview中重新加载特定节?,ios,objective-c,Ios,Objective C,当我尝试重新加载特定的分区时,表格视图会自动向上滚动,但我不明白发生了什么?我使用了下面的代码。当我点击任何按钮时,完整的表格视图会向上滚动 [_moviesDetailTableview beginUpdates]; [_moviesDetailTableview reloadSections:[NSIndexSet indexSetWithIndex:1]withRowAnimation:UITableViewRowAnimationNone];

当我尝试重新加载特定的分区时,表格视图会自动向上滚动,但我不明白发生了什么?我使用了下面的代码。当我点击任何按钮时,完整的表格视图会向上滚动

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

您可以存储tableview的
内容偏移量。可以做一些事情,比如

 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];
}

代码有什么问题?请详细说明您的问题。@Yuvraj Singh您可能正在使用estimatedRowHeigh,它可能与您桌子的实际高度不同。此问题通常是因为这个原因而出现的。它是否发生在ios 8上?您的索引为1的部分是否在可见区域?如果没有,当您重新加载第一部分时,tableview将在那里聚焦…@TusharSharma我使用estimatedRowHeight