首页 > 其他 > 详细

tableViewCell左划显示多个按钮(系统原生)

时间:2016-08-24 11:08:08      阅读:178      评论:0      收藏:0      [点我收藏+]

1、实现tableView的代理方法

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

2、cell添加左划按钮

- (NSArray<UITableViewRowAction *> *)tableView:(UITableView *)tableView editActionsForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    UITableViewRowAction *action0 = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleNormal title:@"修改" handler:^(UITableViewRowAction *action, NSIndexPath *indexPath) {
        NSLog(@"点击了。。%d",indexPath.row);
        
        // 收回左滑出现的按钮(退出编辑模式)
        tableView.editing = NO;
    }];
    action0.backgroundColor = [UIColor darkGrayColor];
    
    UITableViewRowAction *action1 = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleDefault title:@"删除" handler:^(UITableViewRowAction *action, NSIndexPath *indexPath) {

        NSLog(@"删除。。%d",indexPath.row);
        tableView.editing = NO;
    }];
    
    UITableViewRowAction *action2 = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleNormal title:@"删除1" handler:^(UITableViewRowAction *action, NSIndexPath *indexPath) {
        
        NSLog(@"删除1。。%d",indexPath.row);
        tableView.editing = NO;
    }];
    action2.backgroundColor = [UIColor blueColor];
    return @[action1, action0,action2];
    
}

  

tableViewCell左划显示多个按钮(系统原生)

原文:http://www.cnblogs.com/h-tao/p/5801938.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!