需要在[self.tableView endUpdates]完成动画后执行reloadSections

P5y*_*cH0 6 iphone uitableview

我需要表演

[[self tableView] reloadSections:[NSIndexSet indexSetWithIndex:1] withRowAnimation:UITableViewRowAnimationNone];
Run Code Online (Sandbox Code Playgroud)

- (void)controllerDidChangeContent:(NSFetchedResultsController *)controller {
// The fetch controller has sent all current change notifications, so tell the table view to process all updates.
    [self.tableView endUpdates];    
}
Run Code Online (Sandbox Code Playgroud)

完成了动画制作.

我想这样做,因为当从节中删除单元格时,我需要重新配置节中的一些单元格.这是因为该部分的第一个和最后一个单元格具有与它们之间的单元格不同的背景.单个单元格具有不同的背景.如果我不重新配置该部分中剩余的单元格,则可能导致一个难看的视图.

在controllerDidChangeContent期间调用reloadSections太快而崩溃,因为无法再找到一个单元格.

Gen*_*ari 15

如果要将多个参数传递给具有延迟的方法,请将方法调用包装在您自己的方法中:

- (void)reloadSections {
    [self.tableView reloadSections:[NSIndexSet indexSetWithIndex:1]
        withRowAnimation:UITableViewRowAnimationNone];
}
Run Code Online (Sandbox Code Playgroud)

然后当你想重新加载:

[self performSelector:@selector(reloadSections) withObject:nil afterDelay:.2];
Run Code Online (Sandbox Code Playgroud)