#pragma mark 点击删除按钮,提交(或插入....)
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
{
if(editingStyle != UITableViewCellEditingStyleDelete)
return ;
//取到选中行的数据模型
Markboom *mark = _markBoom[indexPath.row];
//修改数据数组
if ([_markBoom containsObject:mark]) {
[_markBoom removeObject:mark];
}
//刷新表格
// [_tableView reloadData];
[_tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationBottom ];
//默认实现手动华东删除的方法
}
//表格的拖动排序
#pragma mark 拖动滑条排序
-(void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)sourceIndexPath toIndexPath:(NSIndexPath *)destinationIndexPath
{
/*
1. 取出要拖动的模型数据
2. 删除之前行的数组
3. 插入新的数据到新的位置
*/
Markboom *mark = _markBoom[sourceIndexPath.row];
[_markBoom removeObject:mark] ;
[_markBoom insertObject:mark atIndex:destinationIndexPath.row];
}
表格(UITableView)的几个小方法
最新推荐文章于 2018-09-20 17:58:55 发布