iOS学习笔记之TableViewCell右侧滑动多项操作

不得不说apple太机智,让我们编程的时候变的方便简洁
好了言归正传,其实右侧滑动多项操作我们只需要实现delegate协议中的- (NSArray<UITableViewRowAction *> *)tableView:(UITableView *)tableView editActionsForRowAtIndexPath:(NSIndexPath *)indexPath 方法就好了,它是返回一个UITableViewRowAction数组,
类UITableViewRowAction描述UITableViewRowAction对象定义了一个单一的行动,现在当用户刷水平表中的行。在一个可编辑的表,执行水平滑动在一行显示一个默认按钮删除行。这个类允许您定义一个或多个自定义动作显示表中给定的一行。这个类的每个实例代表一个单一动作执行,包括文本、格式信息和行为对应的按钮,
这里写图片描述
这里写图片描述
这里写图片描述

#pragma mark --多标签操作
- (NSArray<UITableViewRowAction *> *)tableView:(UITableView *)tableView editActionsForRowAtIndexPath:(NSIndexPath *)indexPath{
    UITableViewRowAction *delete = [UITableViewRowAction             rowActionWithStyle:UITableViewRowActionStyleDefault title:@"删除" handler:^(UITableViewRowAction * _Nonnull action, NSIndexPath * _Nonnull indexPath) {
    //当点击删除执行块中的内容
        [self presentViewController:[self getAlert:@"删除" leeter:@"您确定要删除这条数据吗?" alertText:nil index:indexPath] animated:true completion:nil];

    UITableViewRowAction *insert = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleDefault title:@"修改" handler:^(UITableViewRowAction * _Nonnull action, NSIndexPath * _Nonnull indexPath) {
        [self presentViewController:[self getAlert:@"修改信息" leeter:@"请输入您要删除的信息" alertText:@"请输入您要修改的名称" index:indexPath] animated:true completion:nil];
    }];

    insert.backgroundColor = [UIColor greenColor];
    //返回这两个rowAction到数组
    return @[insert,delete];
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值