iOS8之后,UITableViewRowAction实现滑动多个按钮
#pragma mark - View lifeCycle
- (void)viewDidLoad {
[super viewDidLoad];
self.view.backgroundColor = [UIColor whiteColor];
[self.tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:reuseIdentifier];
} #pragma mark - UITableViewDataSource Methods - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return self.dataArray.count;
} - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:reuseIdentifier];
cell.textLabel.text = self.dataArray[indexPath.row];
return cell;
} #pragma mark - UITableViewDelegate Methods - (NSArray<UITableViewRowAction *> *)tableView:(UITableView *)tableView editActionsForRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewRowAction *deleteAction = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleDestructive title:@"删除" handler:^(UITableViewRowAction * _Nonnull action, NSIndexPath * _Nonnull indexPath) {
NSLog(@"删除-%@", @(indexPath.row));
[self.dataArray removeObjectAtIndex:indexPath.row];
[self.tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationFade];
}]; UITableViewRowAction *otherAction = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleNormal title:@"置顶" handler:^(UITableViewRowAction * _Nonnull action, NSIndexPath * _Nonnull indexPath) {
NSLog(@"置顶-%@", @(indexPath.row));
[self.dataArray exchangeObjectAtIndex:indexPath.row withObjectAtIndex:];
NSIndexPath *toIndexPath = [NSIndexPath indexPathForRow: inSection:indexPath.section];
[self.tableView moveRowAtIndexPath:indexPath toIndexPath:toIndexPath];
}]; return @[deleteAction, otherAction];
} #pragma mark - getter Methods - (NSMutableArray *)dataArray {
if (!_dataArray) {
_dataArray = [NSMutableArray array];
[_dataArray addObjectsFromArray:@[@"Kingdev:row:0",
@"Kingdev:row:1",
@"Kingdev:row:2",
@"Kingdev:row:3",
@"Kingdev:row:4",
@"Kingdev:row:5",
@"Kingdev:row:6",
@"Kingdev:row:7",
@"Kingdev:row:8",
@"Kingdev:row:9",
@"Kingdev:row:10",
@"Kingdev:row:11",
@"Kingdev:row:12"
]];
}
return _dataArray;
}
尊重作者劳动成果,转载请注明: 【kingdev】
iOS8之后,UITableViewRowAction实现滑动多个按钮的更多相关文章
- CSS3学习笔记(4)—上下滑动展开的按钮
最近写了一个动画,下面来看看我以前写的一个上下滑动展开的按钮效果: 这类的效果经常会在一些网站页面下载按钮处看到,当你鼠标悬浮在下载按钮时,会提醒你是否已注册,或者点击登录什么的小提示~~~~~ 一. ...
- cell左右滑动展开更多按钮-MGSwipeTableCell
MGSwipeTableCell是一个UITableViewCell的子类, 它实现了左,右滑动展开更多按钮用来实现一些相关操作就和QQ好友列表滑动展开的按钮一样,封装的很好,动画效果也处理很到位,废 ...
- QQ左侧滑动显示之按钮切换
上一篇为大家介绍了关于自定义属性设置方法,本篇我将为大家介绍一下如何通过按钮来控制Menu的显示和隐藏,为了达到这个效果我们需要在SlidingMenu中添加三个方法,用来达到实现上述效果的目的. 我 ...
- js移动端向左滑动出现删除按钮
最近在做移动端项目时,需要实现一个列表页面的每一项item向左滑动时出现相应的删除按钮,本来想着直接使用zepto的touch.js插件,因为之前实现相同的功能时用过这个插件,当时还挺好用的,直接使用 ...
- Android ListView实现单击item出现删除按钮以及滑动出现删除按钮
我自己一个人弄的公司的产品客户端,所以还是想记录下来以免忘记或者丢失... 在我的上一篇博文(点击打开链接)是一个文件管理的东西,基础组件也是ListView所以在此只是改动一下而已. 单击: 点击出 ...
- 微信小程序列表项滑动显示删除按钮
微信小程序并没有提供列表控件,所以也没有iOS上惯用的列表项左滑删除的功能,SO只能自己干了. 原理很简单,用2个层,上面的层显示正常的内容,下面的层显示一个删除按钮,就是记录手指滑动的距离,动态的来 ...
- [Swift通天遁地]二、表格表单-(7)电子邮件Mail:实现单元格左右滑动调出功能按钮
★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★➤微信公众号:山青咏芝(shanqingyongzhi)➤博客园地址:山青咏芝(https://www.cnblogs. ...
- ios8 tableView设置滑动删除时 显示多个按钮
** * tableView:editActionsForRowAtIndexPath: //设置滑动删除时显示多个按钮 * UITableViewRowAction ...
- Android中Touch事件分析--解决HorizontalScrollView滑动和按钮事件触发问题
之前写过关于HorizontalScrollView滑动和按钮事件触发问题,但是不能所有的情况,最近几天一直在想这个问题,今天有一个比较好的解决思路,最终应用在项目里面效果也很好,首先说明一下功能: ...
随机推荐
- JS高级学习历程-9
昨天内容回顾 1. 作用域链(执行环境.AO.作用.变量性质顺序) 执行环境:最外部有window全局环境,每个函数内部也代表一个环境 每个执行环境内部都有AO活动对象 在函数内部访问的变量信息就是A ...
- iOS 隐藏百度地图SDK的百度LOGO
第一个思路:找到LOGO对应的UIIMageView,并将其隐藏hidden // 隐藏百度地图Logo UIView *mView = _mapView.subviews.firstObject; ...
- echart title属性
title http://echarts.baidu.com/echarts2/doc/doc.html#Title 标题,每个图表最多仅有一个标题控件,每个标题控件可设主副标题. 名称 默认值 描述 ...
- Codeforces Round #433 (Div. 2, based on Olympiad of Metropolises) D
Country of Metropolia is holding Olympiad of Metrpolises soon. It mean that all jury members of the ...
- 什么是微服务架构,.netCore微服务选型
什么是微服务架构,.netCore微服务选型 https://www.cnblogs.com/uglyman/p/9182485.html 开发工具:VS2017 .Net Core 2.1 什么是微 ...
- SSRS-lookupSet-DataSet-分组查询
SSRS-lookupSet-DataSet-分组查询 来源:http://www.cnblogs.com/biwork/p/3621885.html 目录:http://www.cnblogs.co ...
- RabbitMQ使用教程(一)RabbitMQ环境安装配置及Hello World示例
你是否听说过或者使用过队列? 你是否听说过或者使用过消息队列? 你是否听说过或者使用过RabbitMQ? 提到这几个词,用过的人,也许觉得很简单,没用过的人,也许觉得很复杂,至少在我没使用消息队列之前 ...
- nodejs 实践:express 最佳实践(五) connect解析
nodejs 实践:express 最佳实践(五) connect解析 nodejs 发展很快,从 npm 上面的包托管数量就可以看出来.不过从另一方面来看,也是反映了 nodejs 的基础不稳固,需 ...
- 电脑Bois中usb模式启动热键
组装机主板 品牌笔记本 品牌台式机 主板品牌 启动按键 笔记本品牌 启动按键 台式机品牌 启动按键 华硕主板 F8 联想笔记本 F12 联想台式机 F12 技嘉主板 F12 宏基笔记本 F12 惠普台 ...
- VS2013使用EF6通过ADO.NET 连接mySql成功步骤
VS2013使用EF6通过ADO.NET 连接mySql成功步骤 1.安装mysql-for-visualstudio-1.2.6(我用的目前最新版,这个一般安装VS2013就已经有了,没有的话下载一 ...