码迷,mamicode.com
首页 > 其他好文 > 详细

tableView左滑删除功能

时间:2015-06-15 12:55:38      阅读:98      评论:0      收藏:0      [点我收藏+]

标签:

实现三个代理方法即可

技术分享

 

 

-(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];
    }
}

 

tableView左滑删除功能

标签:

原文地址:http://www.cnblogs.com/songxing10000/p/4576791.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!