UItableView 左滑点击可删除

来源:互联网 发布:mac轻量级虚拟机 编辑:程序博客网 时间:2024/06/06 19:27

原版这个网址:http://blog.csdn.net/linux_zkf

实现效果图如下两个图示所示


操作前                                                                                  操作中

IOS UITableView 可删除行实现很简单主要注意两点即可

下面是关键代码

 [self.tableView setEditing:YES animated:YES];

这行设置行为可编辑

删除实现在一下代码中实现

- (void)tableView:(UITableView *)tableView

commitEditingStyle:(UITableViewCellEditingStyle)editingStyle

forRowAtIndexPath:(NSIndexPath *)indexPath {

    NSUInteger row = [indexPath row];

    [self.list removeObjectAtIndex:row];

    [tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath]

                     withRowAnimation:UITableViewRowAnimationFade];

}

其它的和普通的实现一样,这里没有给出代码

其中list为:

 NSMutableArray *list;

0 0
原创粉丝点击