支持iOS6.0以上,最新测试系统为iPhone6 iOS9.2
------3.1更新v1.0.4------
感谢 kallyWang 发现的bug,关于 cellheight 错乱问题,已经修正
------12.23更新v1.0.3------
修正了 bug(didSelectRowAtIndexPath 未响应)
------12.20更新v1.0.2------
1.调整按钮高度为cell高度本身
2.在 translation.x 和 translation.y 上判断条件,在什么时候启用 tablevieW 滚动,并在什么时候启用 cell 动画
------12.20更新v1.0.1------
1.重写 reuse 方法,在进入队列后还原为初始状态
2.optionBtn 点击后,cell 将会还原
3.修复 tableView 上滑下滑时会展开 cell 的 bug
------12.19初始版本v1.0.0------
1.实现 cell 左滑后 btn 自定义
2.可以监测 btn 的四个状态(willshow,didshow,willhide,didhide)和点击事件(clicked)
I 下载 zip 压缩包,将 SCSwipeTableViewCell 文件夹拖动到自己的工程下面
导入 SCSwipeTableViewCell.h
在 tableViewCell 的 delegate 中实现自定义 cell 的侧滑 btn
(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
UIButton *btn1 = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 80, 55)];
btn1.backgroundColor = [UIColor redColor];
[btn1 setTitle:@"删除" forState:UIControlStateNormal];
UIButton *btn2 = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 60, 55)];
btn2.backgroundColor = [UIColor greenColor];
[btn2 setTitle:@"添加" forState:UIControlStateNormal];
btnArr = [[NSMutableArray alloc] initWithObjects:btn1,btn2, nil];
UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(10, 0, self.view.frame.size.width-20, 55)];
label.text = [NSString stringWithFormat:@"swipeCell 测试行 %ld",(long)indexPath.row];
static NSString *cellIdentifier = @"Cell";
SCSwipeTableViewCell *cell = (SCSwipeTableViewCell *)[tableView dequeueReusableCellWithIdentifier:cellIdentifier];
if (cell == nil) {
cell = [[SCSwipeTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault
reuseIdentifier:@"Cell"
withBtns:btnArr
tableView:_tableView];
cell.delegate = self;
}
[cell.SCContentView addSubview:label];
return cell;
}
II 在 pod 上搜索 SCSwipeTableViewCell 直接安装
之前在 Cocoachina 论坛上看到有人写过类似的控件,最近想尝试下写一个这个效果,只是简单的实现了左滑显示自定义btn,右滑显示自定义btn 一样的原理,后面会完善。这个是按照自己的想法写的,和 SWTableViewCell 还有差距,希望多指教!