• IOS UITableViewUITableView小技巧--实现cell向左滑动删除,编辑等功能


    - (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath
    {
        return YES;
    }
    
    - (NSArray<UITableViewRowAction *> *)tableView:(UITableView *)tableView editActionsForRowAtIndexPath:(NSIndexPath *)indexPath{
        UITableViewRowAction *deleteAction = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleDestructive title:@"删除" handler:^(UITableViewRowAction * _Nonnull action, NSIndexPath * _Nonnull indexPath) {
            DSLog(@"点击了删除");
        }];
        UITableViewRowAction *editAction = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleNormal title:@"编辑" handler:^(UITableViewRowAction * _Nonnull action, NSIndexPath * _Nonnull indexPath) {
            DSLog(@"点击了编辑");
        }];
        editAction.backgroundColor = [UIColor grayColor];
        return @[deleteAction, editAction];
    }
    
    - (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath{
        editingStyle = UITableViewCellEditingStyleDelete;
    }
    

      

  • 相关阅读:
    Python初学笔记
    linux学习笔记一----------文件相关操作
    Linux目录结构及常用命令(转载)
    最简单冒泡事件及阻止冒泡事件
    IDEA 从SVN检出项目相关配置
    拦截器实现原理
    CUDA基本概念
    1.2CPU和GPU的设计区别
    RAM和DDR
    Myriad2 简介
  • 原文地址:https://www.cnblogs.com/anakin/p/7889658.html
Copyright © 2020-2023  润新知