tableView编辑样式设计
来源:互联网 发布:双十一卫浴网络销售额 编辑:程序博客网 时间:2024/05/18 03:16
override func tableView(_ tableView: UITableView, editActionsForRowAt indexPath: IndexPath) -> [UITableViewRowAction]? { let actionShare = UITableViewRowAction(style: .default, title: "分享") { (_, indexPath) in let alert = UIAlertController(title: "分享到", message: nil, preferredStyle: .actionSheet) let qq = UIAlertAction(title: "QQ", style: .default, handler: nil) let weixin = UIAlertAction(title: "微信", style: .default, handler: nil) let cancel = UIAlertAction(title: "取消", style: .cancel, handler: nil) alert.addAction(qq) alert.addAction(weixin) alert.addAction(cancel) self.present(alert, animated: true, completion: nil) } actionShare.backgroundColor = UIColor.orange let actionTop = UITableViewRowAction(style: .default, title: "置顶") { (_, indexPath) in self.exchange(indexPath, to: IndexPath(row: 0, section: 0)) tableView.moveRow(at: indexPath, to: IndexPath(row: 0, section: 0)) DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + 0.3, execute: { // 延迟处理 tableView.setEditing(false, animated: true) }) } let actionDele = UITableViewRowAction(style: .destructive, title: "删除"){ (_, indexPath) in self.removeMode(indexPath) tableView.deleteRows(at: [indexPath], with: .fade) print("还剩余数量:",self.ares.count) for area in self.ares { print(area) } } actionTop.backgroundColor = UIColor(red: 245/255, green: 199/255, blue: 244/255, alpha: 1) return [actionDele, actionShare, actionTop] }
一旦实现了上述方法,则下面的方法就不会调用
override func tableView(_ tableView: UITableView, commit editingStyle: UITableViewCellEditingStyle, forRowAt indexPath: IndexPath) { if editingStyle == .delete { // Delete the row from the data source self.removeMode(indexPath) tableView.deleteRows(at: [indexPath], with: .fade) } else if editingStyle == .insert { // Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view } }
0 0
- tableView编辑样式设计
- 自定义tableView编辑样式的图标
- TableView编辑
- TableView编辑
- tableview样式
- 可编辑的TableView
- 设置TableView可编辑
- tableview 编辑整理
- tableView选中状态编辑
- tableView的编辑模式
- tableView - 编辑模式
- tableView的编辑
- tableview的编辑
- tableView的编辑
- 34.tableView的编辑
- IOS-tableview编辑
- tableView - 编辑模式
- tableView的编辑
- rabbitmq学习3:Publish/Subscribe
- 线程同步的几种方式
- 全新安装Win7的好方法
- 纯css3.0打造具有绚丽视差滚动的图片切换
- qt5 plugin
- tableView编辑样式设计
- Vue2.0 新手入门 — 从环境搭建到发布
- 如何解决web浏览器跨域问题——利用反向代理nginx/apache/nodejs
- Java帝国之拨云见日识回调
- 继承与多态
- WebService服务发布与使用
- 2017 Hadoop技术峰会正式启动,这个可以约!
- 基本CSS样式(三)
- 程序员证明自己智商的时候到了,一大波智力面试题正在靠近