在UITableViewCell中进入编辑模式时隐藏UITableViewCells(与Contacts应用程序类似)

有没有人知道如何在编辑模式下进入分组UITableView隐藏一些单元格? 我想要在隐藏编辑模式时隐藏animation效果,如在联系人应用程序中看到的。

如您所知,在联系人编辑模式下,与切换回正常模式相比,行数更多。 我想知道如何顺利​​完成切换。

请注意,我的UITableView子类使用IBOutlets从同一个nib加载静态UITableViewCells。

设置UITableView的编辑模式时,必须先更新数据源,然后插入/删除行。

- (void)setEditing:(BOOL)editing animated:(BOOL)animated { [super setEditing:editing animated:animated]; [tableView setEditing:editing animated:animated]; // populate this array with the NSIndexPath's of the rows you want to add/remove NSMutableArray *indexPaths = [NSMutableArray new]; if(editing) [self.tableView deleteRowsAtIndexPaths:paths withRowAnimation:UITableViewRowAnimationFade]; else [self.tableView insertRowsAtIndexPaths:paths withRowAnimation:UITableViewRowAnimationFade]; [indexPaths release]; } 

只是删除或插入多个行组的更新:

 [self.tableView beginUpdates]; [self.tableView reloadRowsAtIndexPaths: ......]; [self.tableView insertRowsAtIndexPaths: ......]; [self.tableView removeRowsAtIndexPaths: ......]; [self.tableView endUpdates]; 

:d