在UITableViewCell中进入编辑模式时隐藏UITableViewCells(类似于Contacts应用程序) [英] Hiding UITableViewCells when entering edit mode in UITableViewCell (similar to Contacts app)

查看:116
本文介绍了在UITableViewCell中进入编辑模式时隐藏UITableViewCells(类似于Contacts应用程序)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人知道在进入编辑模式时如何从分组的UITableView中隐藏多个单元格?我希望在离开编辑模式时,在联系人应用程序中看到行隐藏动画效果。

Does anyone know how to hide a number of cells from the grouped UITableView when entering in edit mode? I would like the rows to hide with animation effect as seen in the Contacts app when going out of editing mode.

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

As you know, when in Contacts editing mode, there are more rows than when switching back to normal mode. I would like to know how the switching is done smoothly.

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

Note that my UITableView subclass is loading static UITableViewCells from the same nib using IBOutlets.

推荐答案

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

When you set the editing mode of the UITableView, you have to first update your data source and then insert/delete rows.

- (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];
}

这篇关于在UITableViewCell中进入编辑模式时隐藏UITableViewCells(类似于Contacts应用程序)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆