在我的一个表格 View 的编辑模式中,我从一个部分中删除了一行。下面的部分有一个标题。删除上一节中的行会导致下面的节标题重复。所以我有 2 个标题,一个在另一个之上。
我还尝试在删除后强制重新加载该部分,但无济于事:
[self.tableView beginUpdates];
[self.tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:YES];
NSIndexSet * indexSet = [[NSIndexSet alloc] initWithIndexesInRange:NSMakeRange(3,1)];
[self.tableView reloadSections:indexSet withRowAnimation:UITableViewRowAnimationFade];
[indexSet release];
[self.tableView endUpdates];
对我做错了什么有什么想法吗?
有趣的是,未能删除的 header 并未“被看到”。如果我向右滚动 TableView 的内容,然后让它弹回,则只能看到顶部标题 View 。它总是忽略应该被删除的 header 。
最佳答案
我尝试了不同的方式(注释代码),但最后开始和结束更新技术有效。谢谢巨龙。
[self.tableView beginUpdates];
[tableView reloadSections:[NSIndexSet indexSetWithIndex:section] withRowAnimation:UITableViewRowAnimationFade];
[tableView scrollRectToVisible:[tableView rectForSection:section] animated:YES];
//[tableView setNeedsDisplay];
//[self.view setNeedsDisplay];
[self.tableView endUpdates];
关于iphone - 如果从上面的部分中删除一行,则该部分下面的标题会重复,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1673819/