zoukankan      html  css  js  c++  java
  • tableViewCell左划显示多个按钮(系统原生)

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

      

  • 相关阅读:
    Sql获取表中随机1到n条数据
    SQLite相关
    Eclipse自动生成api时报错“警告: 编码 GBK 的不可映射字符”
    Git基础命令
    Oracle查询结果行转列,列转行
    字符串编码方式转换
    Java字符串匹配正则表达式
    python爬虫--编码问题y
    GET与POST方法
    python爬虫(1)--Urllib库的基本使用
  • 原文地址:https://www.cnblogs.com/h-tao/p/5801938.html
Copyright © 2011-2022 走看看