UITableView实现Cell的滑动删除
2013-09-29 11:29
211 查看
- (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath //当在Cell上滑动时会调用此函数 { if(temp == 1 || temp == 2) return UITableViewCellEditingStyleDelete; //返回此值时,Cell会做出响应显示Delete按键,点击Delete后会调用下面的函数,别给传递UITableViewCellEditingStyleDelete参数 else return UITableViewCellEditingStyleNone; //返回此值时,Cell上不会出现Delete按键,即Cell不做任何响应 } - (void) tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath //对选中的Cell根据editingStyle进行操作 { if (editingStyle == UITableViewCellEditingStyleDelete) { if (temp == 1) //将单元格从数据库1中删除 { [[CommonDatainstance] delEntity:[[[CommonDatainstance] gainSelectResult] objectAtIndexPath:indexPath]]; [[CommonDatainstance] saveDB]; [[CommonDatainstance] refreshResult:[[CommonDatainstance] gainSelectResult]]; NSArray *array = [[CommonDatainstance] gainSelectResult].fetchedObjects; array = [[self changeArrayForm:array] copy]; self.listData = array; [myTableView reloadData]; } else if (temp == 2) ////将单元格从数据库2中删除 { [[CommonDatainstance] delEntity:[[[CommonDatainstance] gainRecentResult] objectAtIndexPath:indexPath]]; [[CommonDatainstance] saveDB]; [[CommonDatainstance] refreshResult:[[CommonDatainstance] gainRecentResult]]; NSArray *array = [[CommonDatainstance] gainRecentResult].fetchedObjects; array = [[self changeArrayForm:array] copy]; self.listData = array; [myTableView reloadData]; } } }
相关文章推荐
- UITableView小技巧--实现cell向左滑动删除,编辑等功能
- [IOS]UITableView实现Cell的滑动删除
- UITableView实现Cell的滑动删除
- IOS UITableViewUITableView小技巧--实现cell向左滑动删除,编辑等功能
- UITableView实现Cell的滑动删除
- UITableView实现Cell的滑动删除
- UITableView小技巧--实现cell向左滑动删除,编辑等功能
- UITableView的实现过程,滑动,alter弹窗删除对象
- iOS UITableView 支持滑动删除 Cell
- iOS 开发 UItableView中滑动删除 cell
- iOS UITableView中CELL添加计时器实现自动删除的问题
- ios UITableView实现单击提示,滑动删除,多选行等操作
- 滑动删除uitableview cell
- Swift学习之UITableView的实现以及滑动删除
- UIday1002:UITableView 2 用UITableView实现通讯录cell简单的数据移动、删除、添加功能
- iOS项目开发小技巧 (三) --UITableView实现Cell左划删除等自定义功能
- iOS开发:UITableView实现侧滑删除cell的功能
- UITableView 滑动Cell删除
- UITableView划动删除cell一行的实现
- UItableView中滑动删除 cell