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滑动和按钮事件触发问题,但是不能所有的情况,最近几天一直在想这个问题,今天有一个比较好的解决思路,最终应用在项目里面效果也很好,首先说明一下功能: ...
 
随机推荐
- pytest框架(一)
			
代码示例一 # coding=utf-8 def func(x): return x + 1 def test_answer(): assert func(3) == 5 运行结果 E:\pyYouY ...
 - 手工sql注入判断是否存在注入点
			
1.加入单引号 ’提交,结果:如果出现错误提示,则该网站可能就存在注入漏洞.2.数字型判断是否有注入;语句:and 1=1 ;and 1=2 (经典).' and '1'=1(字符型)结果:分别返回不 ...
 - Tomcat 指定jdk
			
Windows 下 修改 tomcat根目录/bin/setclasspath.bat 文件 如下: rem Otherwise either JRE or JDK are fine set JAVA ...
 - qBittorrent+Flex搭建在线视频播放网站
			
BT下载工具qbittorrent(当然这里也有其他类似的工具可选如transmission等) 首先安装EPEL源: yum -y install epel-release 安装开发工具包: yum ...
 - HTTP2 Sampler for JMeter
			
今天开发大大说能不能帮忙压一下HTTP2的链接,便去查了一下相关的东西. HTTP 2.0 的出现,相比于 HTTP 1.x ,大幅度的提升了 web 性能.在与 HTTP/1.1 完全语义兼容的基础 ...
 - yii2.0下,JqPaginator与Pjax实现无刷新翻页
			
控制器部分 <?php namespace backend\controllers; use common\models\Common; use Yii; use yii\base\Contro ...
 - mysql 驱动问题
			
转 : https://blog.csdn.net/bloodycuckoo/article/details/51175339 转 : https://blog.csdn.net/u010746431 ...
 - DatabaseMetaData类
			
DatabaseMetaData类是java.sql包中的类,利用它可以获取我们连接到的数据库的结构.存储等很多信息.如: 1.数据库与用户,数据库标识符以及函数与存储过程. 2.数据 ...
 - cf519D. A and B and Interesting Substrings(前缀和)
			
题意 给出$26$个字母对应的权值和一个字符串 问满足以下条件的子串有多少 首尾字母相同 中间字母权值相加为0 Sol 我们要找到区间满足$sum[i] - sum[j] = 0$ $sum[i] = ...
 - javaweb-servlet生成简单的验证码
			
package com.serv; import java.awt.Color; import java.awt.Graphics; import java.awt.image.BufferedIma ...