我能够deleteSections
按部分进行调用:
static int nos = 4;
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return nos;
}
-(IBAction)onFadeTableButton:(id)sender
{
NSMutableIndexSet *sectionsToDelete = [NSMutableIndexSet indexSet];
[sectionsToDelete addIndex:3];
nos = 3;
[self.tableView deleteSections:sectionsToDelete
withRowAnimation:UITableViewRowAnimationTop];
[sectionsToDelete addIndex:2];
[sectionsToDelete removeIndex:3];
nos = 2;
[self.tableView deleteSections:sectionsToDelete
withRowAnimation:UITableViewRowAnimationMiddle];
[sectionsToDelete addIndex:1];
[sectionsToDelete removeIndex:2];
nos = 1;
[self.tableView deleteSections:sectionsToDelete
withRowAnimation:UITableViewRowAnimationMiddle];
[sectionsToDelete addIndex:0];
[sectionsToDelete removeIndex:1];
nos = 0;
[self.tableView deleteSections:sectionsToDelete
withRowAnimation:UITableViewRowAnimationMiddle];
}
代码很丑,因为我很快就使用了一个现有的项目(有 4 个部分的表格视图),但这个想法必须清楚。不要照原样使用它,请让它美丽。