Cell的滑动删除 ios8之后和之前
来源:互联网 发布:通勤车自行车推荐知乎 编辑:程序博客网 时间:2024/05/17 22:20
在Ios8之后这个api实现cell滑动删除方便多了,还可以设置按钮个数以及各种属性:
-(NSArray *)tableView:(UITableView *)tableView editActionsForRowAtIndexPath:(nonnullNSIndexPath *)indexPath{
UITableViewRowAction *delete = [UITableViewRowActionrowActionWithStyle:UITableViewRowActionStyleDefaulttitle:@"删除"handler:^(UITableViewRowAction *_Nonnull action,NSIndexPath *_Nonnull indexPath) {
[_arrayremoveObjectAtIndex:indexPath.row];
[tableView deleteRowsAtIndexPaths:[NSMutableArrayarrayWithObject:indexPath]withRowAnimation:UITableViewRowAnimationFade];
}];
UITableViewRowAction *top = [UITableViewRowActionrowActionWithStyle:UITableViewRowActionStyleDefaulttitle:@"置顶"handler:^(UITableViewRowAction *_Nonnull action,NSIndexPath *_Nonnull indexPath) {
//...
}];
top.backgroundColor = [UIColorgrayColor];
return@[delete,top];
}
//系统默认为'delete',修改为'删除'
- (NSString *)tableView:(UITableView *)tableView titleForDeleteConfirmationButtonForRowAtIndexPath:(NSIndexPath *)indexPath
{
return@"删除";
}
//设置编辑样式为(删除)
- (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath
{
returnUITableViewCellEditingStyleDelete;
}
//提交操作
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
if (editingStyle ==UITableViewCellEditingStyleDelete) {
[_arrayremoveObjectAtIndex:indexPath.row];
[tableView deleteRowsAtIndexPaths:[NSMutableArrayarrayWithObject:indexPath]withRowAnimation:UITableViewRowAnimationFade];
} elseif (editingStyle ==UITableViewCellEditingStyleInsert) {
//...
}
}
- Cell的滑动删除 ios8之后和之前
- iOS开发之有趣的UI —— iOS8之前和之后的自定义不等高cell
- 实现Cell的滑动删除
- iOS 解决cell滑动删除和scrollView左右滑动之间的冲突
- UITableView实现Cell的滑动删除
- [IOS]UITableView实现Cell的滑动删除
- UITableView实现Cell的滑动删除
- UITableView实现Cell的滑动删除
- iOS8之后tableView cell自动计算高度
- 滑动删除uitableview cell
- UITableView 滑动Cell删除
- iOS 滑动删除cell
- UITableViewCell左滑动删除 和cell上按钮的点击事件
- ios8之后的UIAlertController
- iOS8之后的UIAlertViewController
- 关于iOS8之前和以后的相册图片获取实现
- ios8和之前系统[UIScreen mainScreen].bounds的不一样
- UItableView中滑动删除 cell
- 一些于算法相关的网站
- Netty学习之旅------再谈线程模型之源码分析NioEventLoopGroup、SingleThreadEventExecutor
- 随意写的
- ELF文件和BIN文件 201
- iOS @property探究(二): 深入理解
- Cell的滑动删除 ios8之后和之前
- 在 Word 2013 中编写公式并标号
- vi/vim 基础快速操作易查手册
- 存储过程调用存储过程数据集的方法
- Word测试发博客
- java接口 (springmvc)
- 第二个ffmpeg程序,视频播放
- 算法导论 练习题 4.1-5
- python: strip()函数