tableView左滑删除功能
2015-06-15 12:03
281 查看
实现三个代理方法即可
上面说漏了一点,就是有个代理方法是开启允许进入编辑状态的,这样才可以进行左滑或者添加的其他操作,注意当你左滑后,没有把这个cell滑回去,这时候如果你在返回上一个页面可能会崩溃,这个时候你需要在viewWillDisappear方法中将这个编辑状态置为NO,好的,现在终于操作流畅了。
-(NSString *)tableView:(UITableView *)tableView titleForDeleteConfirmationButtonForRowAtIndexPath:(NSIndexPath *)indexPath { return @"删除"; } -(UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath { if (!indexPath.section) return UITableViewCellEditingStyleNone; // 第一组家和公司不提供左滑删除功能 return UITableViewCellEditingStyleDelete; } - (void)tableView:(UITableView*)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath*)indexPath { if (editingStyle == UITableViewCellEditingStyleDelete) { [self.commonPlaceArray removeObjectAtIndex:indexPath.row]; [self.tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationAutomatic]; [self.tableView reloadData]; } }
上面说漏了一点,就是有个代理方法是开启允许进入编辑状态的,这样才可以进行左滑或者添加的其他操作,注意当你左滑后,没有把这个cell滑回去,这时候如果你在返回上一个页面可能会崩溃,这个时候你需要在viewWillDisappear方法中将这个编辑状态置为NO,好的,现在终于操作流畅了。
相关文章推荐
- java8中的Stream
- 如何在 Linux 上用 IP转发使内部网络连接到互联网
- phpExcel导出excel
- win7下硬盘安装win7+CentOS双系统方法
- MySQL 简单存储过程实现Redis的INCR功能
- 修己
- 【算法】模拟掷骰子
- 程序员层级---程序员的10层楼
- 简述JavaScript中正则表达式的使用方法
- BigDecimal类的加减乘除
- 久邦数码:为何起大早赶晚集?
- 程序打包 之 NSIS脚本
- 微信支付.net官方坑太多,我们来精简
- PHP判断是否微新浏览器
- asp.net下拉框部分不可选与分类显示
- 雷军的“敌人”为何总是那么多?
- Installing the Neurosky Mindwave Mobile on Windows 7 computer
- easyui刷新当前页
- android 控件在不同状态下的内容样式与背景样式
- DRBD的简单实现