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

}

  

时间: 2024-07-31 19:09:29

tableViewCell左划显示多个按钮(系统原生)的相关文章

UITableViewCell左滑显示按钮菜单

http://blog.jobbole.com/67272/ 编辑模式下左滑可以显示DELETE按钮.如何可以自定义左滑显示的按钮呢? 整体思路 1.自定义UITableViewCell,并为其contentView添加左滑时希望显示的按钮. 2.在contentView上添加一个相同大小subView,作为正常情况下tableViewCell显示的内容. 3.为此subView添加pan事件,滑动的时候移动其位置,使按钮可以显示出来. 需要注意的问题 具体实现(仿微信效果) 新建自定义的Tab

高仿微信实现左滑显示删除按钮功能

在实际项目中删除列表中的某一项是非常常见的功能,传统的做法可以使用长按监听器等,而现在流行的做法是左滑弹出删除按钮,微信,QQ等都是这么做的,下面做一个示例,代码如下: 主页面MainActivity:代码比较简单常规 package com.home.testslideview; import java.util.ArrayList; import java.util.List; import android.app.Activity; import android.os.Bundle; im

ios8 tableView设置滑动删除时 显示多个按钮

** *  tableView:editActionsForRowAtIndexPath:     //设置滑动删除时显示多个按钮 *  UITableViewRowAction                        //通过此类创建按钮 *  1. 我们在使用一些应用的时候,在滑动一些联系人的某一行的时候,会出现删除.置顶.更多等等的按钮,在iOS8之前,我们都需要自己去实现.但是,到了iOS8,系统已经写好了,只需要一个代理方法和一个类就搞定了 *  2. iOS8的协议多了一个方法

ios8 tableView设置滑动删除时显示多个按钮

镔哥,研究很久最后才发现iOS8 TableView出新功能,然后就记下来,供大家参考,为大伙所用. 看我博客都知道,我一向都是喜欢代码注释结合,提供demo给大伙参考,写得不好,不要见怪哦. ** *  tableView:editActionsForRowAtIndexPath:     // 设置滑动删除时显示多个按钮 *  UITableViewRowAction                        // 通过此类创建按钮 *  1. 我们在使用一些应用的时候,在滑动一些联系人

uploadify不能正确显示中文的按钮文本的解决办法

uploadify 目前不能正确显示中文的按钮文本. 我发现bug的原因是uploadify错误的使用了 js 的 escape 和 flash 的 unescape配对,而这2个是不兼容的.正确的转码传递参数应该用 encodeURI/decodeURI 配对,这2个函数的行为在js和flash里是相同的.其他地方的escape/unescape也应该替换掉,下面只修改影响按钮文本的部分.1. jquery.uploadify.v2.1.4.js 70行 将if (settings.butto

UITableView 左划删除

-(BOOL) tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath { returnYES; } -(void) tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPat

iOS自定义全屏返回与tableView左划删除手势冲突解决

当自定义一个navigationController实现全屏右划返回时, 使用起来是不是很爽, 代码如下: - (void)viewDidLoad { [super viewDidLoad]; UIGestureRecognizer *gester = self.interactivePopGestureRecognizer; UIPanGestureRecognizer *panGesTer = [[UIPanGestureRecognizer alloc] initWithTarget:ge

使用swift在sprite中显示圆角UIButton按钮

我对objective-C不是很熟,UIKit以前没有用过,SpriteKit也只看了遍教程,然后看了一遍swift语言教程,此时开始编写这个程序,所以遇到的问题比较小儿科,解决方法也是曲线救国,希望有高人指点解决这些问题的简单方法,有好的解决方法后,我会随时进行本日志的修改,以免误导他人. 程序界面很是简单 然后点击中间的游戏区域,会roll色子,随机产生1~6的数字,飞机前进若干步,遇到梯子向前跳若干步,而遇到蛇则后退若干步,指导抵达25格,游戏结束. 上面有一个标签,显示游戏状态和Roll

iOS开发---UIButton 1 //创建一个可以显示图片的按钮。

1 //创建一个可以显示图片的按钮. 2 -(void)creatImageBtn{ 3 UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom]; 4 btn.frame = CGRectMake(100, 100, 100, 100); 5 UIImage *icon1 = [UIImage imageNamed:@"icon1.png"]; 6 UIImage *icon2 = [UIImage imageNamed