博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
iOS 设计中实现Cell自定义滑块操作
阅读量:4657 次
发布时间:2019-06-09

本文共 1345 字,大约阅读时间需要 4 分钟。

    1. ☐ //实现Cell自定义滑动操作.........
      -(NSArray<UITableViewRowAction *> *)tableView:(UITableView *)tableView editActionsForRowAtIndexPath:(NSIndexPath *)indexPath
      {
          //添加一个删除按钮
          UITableViewRowAction *Top1=[UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleDestructive title:@"删除" handler:^(UITableViewRowAction * _Nonnull action, NSIndexPath * _Nonnull indexPath)
      {
          //更新数据
          [self.Array removeObjectAtIndex:indexPath.row];
          //更新 tableview
        [tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationAutomatic];
        //反馈执行 删除操作
         NSLog(@"删除");
       [tableView setEditing:NO animated:YES];
          }];
          //添加按钮背景色
          Top1.backgroundColor=[UIColor redColor];
         
      //添加一个置顶按钮
      UITableViewRowAction *Top2=[UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleDestructive title:@"置顶" handler:^(UITableViewRowAction * _Nonnull action, NSIndexPath * _Nonnull indexPath)
      {
          //刷新数据
      [self.Array exchangeObjectAtIndex:indexPath.row withObjectAtIndex:0];
      //把所选项置顶
          NSIndexPath *FirstIndexPath=[NSIndexPath indexPathForRow:0 inSection:indexPath.section];
      [tableView moveRowAtIndexPath:indexPath toIndexPath:FirstIndexPath];
      //反馈执行置顶操作
       NSLog(@"置顶");
      [tableView setEditing:NO animated:YES];
                                      }];
      //设置按钮的背景色
          Top2.backgroundColor=[UIColor grayColor];
         
         
      //返回我们所设置的按钮 但是得以数组的形式返回
          return @[Top1,Top2];
         
      }

转载于:https://www.cnblogs.com/guiyangxueyuan/p/5313328.html

你可能感兴趣的文章
Navicat不能连接linux数据库问题
查看>>
centos7关闭防火墙
查看>>
《C#高级编程》 读书笔记 -索引
查看>>
session cookie原理及应用
查看>>
ID3算法详解
查看>>
BZOJ1925: [Sdoi2010]地精部落
查看>>
学习进度条第十一周
查看>>
linux常用命令
查看>>
python 之Twsited
查看>>
设置SQL PLUS环境
查看>>
关于虚拟机VM
查看>>
eclipse、tomca和jvm的相关内存配置
查看>>
python的迭代器
查看>>
spy memcached spring demo
查看>>
Python基础语法
查看>>
4.1.1 硬币游戏
查看>>
获取服务器信息
查看>>
JavaScript_5_对象
查看>>
MyBatis总结五:#{}和${}的用法和区别
查看>>
OO’s Sequence
查看>>