iOS tableView侧滑删除的第三方控件
(到我的文件中,下载“tableview中cell测滑删除的第三方控件”),使用方法如下:
在tableView中的.m中,设置cell的方法上,事例代码如下,其中,EaseConversationCell继承于LYSideslipCell:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
NSString *CellIdentifier = [EaseConversationCell cellIdentifierWithModel:nil];
EaseConversationCell *cell = (EaseConversationCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[EaseConversationCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}
cell.consultModel = self.dataArray[indexPath.section];
//添加侧滑之后的按钮
KDButton *deleteBtn = [cell rowActionWithStyle:LYSideslipCellActionStyleNormal title:nil];
deleteBtn.index = indexPath.row;
deleteBtn.section = indexPath.section;
deleteBtn.backgroundColor =[UIColor redColor];
[deleteBtn setBackgroundImage:kUIImage(@"delete") forState:UIControlStateNormal];
[deleteBtn addTarget:self action:@selector(deleteBtn:) forControlEvents:UIControlEventTouchUpInside];
[cell setRightButtons:@[deleteBtn]];//可以传多个
cell.selectionStyle = UITableViewCellSelectionStyleNone;
return cell;
}
效果图如下:

(参考代码:美业B端-MYBConsultViewController.m)
其中,这个控件的好处是,可以监听到cell侧滑时的动作,比如需要在侧滑后改变cell的颜色,这个控件就可以实现到,在LYSideslipCell.m中:监控如下这两个方法即可:
- (void)hiddenSideslipButton {
//侧滑恢复后的操作
if (_containLeftConstraint.constant == ) return;
[self closeAllOperation];
_containLeftConstraint.constant = _sideslipLeftConstraint.constant = ;
[UIView animateWithDuration:0.2 delay: options:UIViewAnimationOptionCurveLinear animations:^{
[self layoutIfNeeded];
} completion:^(BOOL finished) {
[self openAllOperation];
}];
_backGroundView.backgroundColor = UIColorFromRGB(0xF7F7F7);
_backGroundView.frame = CGRectMake(, , kScreenW - , );
}
- (void)showSideslipButton {
//侧滑后的操作
[self closeAllOperation];
_containLeftConstraint.constant = _sideslipLeftConstraint.constant = -CGRectGetWidth(_sideslipView.frame);
[UIView animateWithDuration:0.2 delay: options:UIViewAnimationOptionCurveLinear animations:^{
[self layoutIfNeeded];
} completion:^(BOOL finished) {
for (LYSideslipCell *cell in self.tableView.visibleCells)
if ([cell isKindOfClass:LYSideslipCell.class]) {
cell.userInteractionEnabled = YES;
}
}];
_backGroundView.backgroundColor = UIColorFromRGB(0xE7F8FF);
_backGroundView.frame = CGRectMake(, , kScreenW - , );
}
:
iOS tableView侧滑删除的第三方控件的更多相关文章
- iOS开发无第三方控件的援助达到的效果侧边栏
最近的研究iOS程序侧边栏.渐渐的发现iOS该方案还开始采取风侧边栏格该,QQ,今日头条,Path(Path运营商最早的侧边栏app该,效果说成是Path效果),所以就研究了下. 然后发现Git Hu ...
- IOS中tableView每组的头部控件、通过tableView的代理方法控制某一行的cell能否达到高亮选中状态
一.tableView每组的头部控件 1.控件宽度默认就是tableView的宽度 2.控件高度由下面的代理方法决定 - (CGFloat)tableView:(UITableView *)table ...
- 好用的第三方控件,Xcode插件(不断更新)
第三方控件类: 1.提示框 MBProgressHUD: 是一款非常强大的.提供多种样式的提示框.使用起来简单.方便.可以在GitHub上查看具体的使用方法. https://github.com ...
- 教程-Delphi第三方控件安装卸载指南
1 只有一个DCU文件的组件.DCU文件是编译好的单元文件,这样的组件是作者不想把源码公布.一般来说,作者必须说明此组件适合Delphi的哪种版本,如果版本不对,在安装时就会出现错误.也正是因为没有源 ...
- Delphi7第三方控件
控件安装(安装时建议先关闭Delphi) 1.只有一个DCU文件的组件. DCU文件是编译好的单元文件,这样的组件是作者不想把源码公布.一般来说,作者必须说明此组件适合Delphi的哪种版本,如果版本 ...
- Delphi第三方控件安装卸载指南
基本安装1.对于单个控件,Componet-->install component..-->PAS或DCU文件-->install; 2.对于带*.dpk文件的控件包,File--& ...
- iOS开发UI篇—手写控件,frame,center和bounds属性
iOS开发UI基础—手写控件,frame,center和bounds属性 一.手写控件 1.手写控件的步骤 (1)使用相应的控件类创建控件对象 (2)设置该控件的各种属性 (3)添加控件到视图中 (4 ...
- Delphi7 第三方控件1stClass4000的TfcImageBtn按钮控件动态加载jpg图片例子
Delphi7 第三方控件1stClass4000的TfcImageBtn按钮控件动态加载jpg图片例子 procedure TForm1.Button1Click(Sender: TObject); ...
- delphi使用 第三方控件
第三方控件安装时必须把所有的pas,dcu,dpk,res等文件复制到你的Lib目录下 然后通过dpk进行安装 安装后会多出来新的控件面板,新控件就在那里了 当然也有一些控件会安装到原有的面板上 比如 ...
随机推荐
- C++中的传值与传址
在指针的传递中,也涉及到传值与传址的问题.下面通过一个函数进行说明. 代码如下: bool openBinary(uchar* buffer) { ; buffer = (uchar*)malloc( ...
- Oracle 双机热备+双机冷备+负载均衡
引用地址:https://wenku.baidu.com/view/7cca62f1ddccda38366baf7f.html SQL Server 2008 R2双机热备 引用地址:https:// ...
- Centos 7+KVM(Windows Server 2008 r2 )
KVM虚拟机 Kernel-based Virtual Machine的简称,是一个开源的系统虚拟化模块,自Linux 2.6.20之后集成在Linux的各个主要发行版本中.它使用Linux自身的调度 ...
- git 推送本地项目到远程库
git 推送本地项目到远程库 1@DESKTOP-3H9092J MINGW64 /e/mozq/00store/01/SmartCard_MS $ git init Initialized empt ...
- 《从HBase offheap到Netty的内存管理》
JVM中的堆外内存(off-heap memory)与堆内内存(on-heap memory) 1. 堆内内存(on-heap memory) 1.1 什么是堆内内存 Java 虚拟机在执行Jav ...
- 《RocketMQ》
作为一款消息中间件,RocketMQ需要解决的技术问题其实在分布式系统领域中都有所体现.首先如果将分布式系统的领域按照分布式通信.分布式存储.分布式计算以及分布式管理这四大部分进行划分,其实就会发现在 ...
- angular 多路由模块新建组件的方法
More than one module matches. Use skip-import option to skip importing the component into the closes ...
- 使用system V实现读者写者问题
#include <stdio.h> #include <sys/sem.h> #include <sys/ipc.h> #include <string.h ...
- [LOJ 2133][UOJ 131][BZOJ 4199][NOI 2015]品酒大会
[LOJ 2133][UOJ 131][BZOJ 4199][NOI 2015]品酒大会 题意 给定一个长度为 \(n\) 的字符串 \(s\), 对于所有 \(r\in[1,n]\) 求出 \(s\ ...
- Paper | Squeeze-and-Excitation Networks
目录 1. 故事 2. SENet 2.1 概况 2.2 具体 3. 实验 本文的贡献点在于:通过显式建模特征注意力机制,达到了很好的效果.这是以往被默认隐式学习的操作.并且注意,此时建模出来的注意力 ...