ios UITableView自带划动删除效果

时间:2014-06-08 10:48:34   收藏:0   阅读:320


说实话,UITableView cell自带的滑动删除效果,在ios7以前比较丑,但ios扁平化后,这个滑动删除还是非常好看的。而且实现起来也是非常容易的。

实现这个效果主要是在UITableView协议里面实现。

如下:

设置可以编辑

- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath{
    return YES;
}


删除按钮点击

- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath{
    if (editingStyle == UITableViewCellEditingStyleDelete) {
        //todo
    }
}


这里默认删除的按钮为英文,想要改变成中文,需要再实现一个方法。

- (NSString *)tableView:(UITableView *)tableView titleForDeleteConfirmationButtonForRowAtIndexPath:(NSIndexPath *)indexPath NS_AVAILABLE_IOS(3_0){
    return @" 删除 ";
}


效果如下:



bubuko.com,布布扣




ios UITableView自带划动删除效果,布布扣,bubuko.com

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!