【swift3.0】【tableView 侧滑删除展示】
2016-12-25 00:00
337 查看
贡献作者 -【XJDomain】
博客XJ: https://my.oschina.net/shengbingli/blog GitHub直播地址: https://github.com/lishengbing/XJDomainLive
1:展示一个系统自定的删除按钮方式_1
1.1:展示一个系统自定的删除按钮方式_2
2.修改展示的字样
3:删除的点击事件获取
4:展示tableview cell侧滑多个按钮显示的方式:一个方法搞定!!!
博客XJ: https://my.oschina.net/shengbingli/blog GitHub直播地址: https://github.com/lishengbing/XJDomainLive
1:展示一个系统自定的删除按钮方式_1
override func tableView(_ tableView: UITableView, editingStyleForRowAt indexPath: IndexPath) -> UITableViewCellEditingStyle { if indexPath.section == 0 { return .none } return UITableViewCellEditingStyle.delete }
1.1:展示一个系统自定的删除按钮方式_2
override func tableView(_ tableView: UITableView, canEditRowAt indexPath: IndexPath) -> Bool { if indexPath.section == 0 { return false } return true }
2.修改展示的字样
override func tableView(_ tableView: UITableView, titleForDeleteConfirmationButtonForRowAt indexPath: IndexPath) -> String? { return "删除" }
3:删除的点击事件获取
override func tableView(_ tableView: UITableView, commit editingStyle: UITableViewCellEditingStyle, forRowAt indexPath: IndexPath) { if editingStyle == .delete { print("删除事件.....") } }
4:展示tableview cell侧滑多个按钮显示的方式:一个方法搞定!!!
override func tableView(_ tableView: UITableView, editActionsForRowAt indexPath: IndexPath) -> [UITableViewRowAction]? { let item1 = UITableViewRowAction(style: .normal, title: "item1") { (action, indexPath) in print("item1-----") } item1.backgroundColor = UIColor.green let item2 = UITableViewRowAction(style: .destructive, title: "item2") { (action, indexPath) in print("item2-----") } item2.backgroundColor = UIColor.blue let dele = UITableViewRowAction(style: .normal, title: "删除") { (action, indexPath) in print("dele-----",action) action.backgroundColor = UIColor.orange } dele.backgroundColor = UIColor.red //dele.backgroundEffect = UIBlurEffect(style: UIBlurEffectStyle.light) return [dele, item1, item2] }
相关文章推荐
- swift tableview中添加侧滑删除功能 类似qq删除
- iOS开发tableview 的cell 侧滑删除
- 0819-TableView(tableVeiw控件的代理)(tableView单组 lol数据展示)(tableView-汽车品牌logo 右侧a-z)(KVC)(tableView - 添加删除按钮出现)(自定义代理delegate)(内存)
- ios tableview cell 侧滑删除
- tableView上的侧滑删除功能
- tableviewcell 侧滑删除 点击返回按钮 程序崩溃 [ tableView:canEditRowAtIndexPath:]:message sent to deallocated insta
- [绍棠] tableView侧滑显示多个按钮, 如删除, 置顶, 更多
- 侧滑返回和TableView滑动删除手势冲突完美解决
- [IOS]包含增删改查移动的tableView展示+plist文件保存+程序意外退出保存Demo
- IOS学习笔记(10)UITableView展示数据 cell删除 构建页眉页脚
- tableView中动态添加,删除行
- Cocos2d-x学习之---关于CCTableView中reloadData()操作,删除第一个/最后一个cell后tableview位置未刷新的问题
- [IOS]包含增删改查移动的tableView展示+plist文件保存+程序意外退出保存Demo
- 用TableView做的新闻客户端展示页面
- ios Tableview 左右手势 显示 删除 按钮
- ios tableView那些事 (九) tableview的删除
- iOS tableView 如何禁止滑动手势删除,只允许在编辑模式下进行删除Cell
- ios tableView那些事 (九) tableview的删除
- 仿tableview接口实现zaker首页效果(画n*m布局、拖动排序、删除)
- 删除tableview的section遇到crash:The number of rows contained in an existing section after the update