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

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

时间:2016-08-24 11:08:56      阅读:102      评论: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
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!