iphone - 如果从上面的部分中删除一行,则该部分下面的标题会重复

标签 iphone uitableview header

在我的一个表格 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/

相关文章:

ios - 我需要苹果 MFI 程序才能通过 USB 电缆访问 IOS 设备的短信吗?

iphone - iPad 自定义键盘样式?

iphone - shouldAutorotateToInterfaceOrientation 有问题

ios - TableView 中的警告

php - jQuery ajax 回到 $_POST 而不是 REQUEST 负载

networking - ICMP header 校验和是否也包含数据?

iphone - 谁能告诉我如何使用 libHaru 库创建带有文本注释的 PDF

ios - 动态 UITableViewCell 不根据内容调整大小

ios - 如何创建 ReloadRow 动画

c++ - 为 conio.h 使用另一个 header