大佬教程收集整理的这篇文章主要介绍了ios – 允许UITableView重新排序,但不能在编辑模式下删除,并启用滑动删除,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
为此,我实施了
override func setEdiTing(ediTing: Bool,animated: Bool) { super.setEdiTing(ediTing,animated:animated) if (!isInSwipedeleteModE) { if (self.tableView.ediTing) { MetaJourPersonnes() tableView.reloadData() } else { tableView.reloadData() } } } override func tableView(tableView: UITableView,canMoveRowATindexPath indexPath: NSIndexPath) -> Bool { if (indexPath.row < personnes.count) { return true } else { return false } } override func tableView(tableView: UITableView,moveRowATindexPath sourceIndexPath: NSIndexPath,toIndexPath desTinationIndexPath: NSIndexPath) { let pers = personnes[sourceIndexPath.row] personnes.removeATindex(sourceIndexPath.row) if (desTinationIndexPath.row < personnes.count) { personnes.insert(pers,aTindex: desTinationIndexPath.row) } else { personnes.append(pers) } tableView.reloadData() } override func tableView(tableView: UITableView,ediTingStyleForRowATindexPath indexPath: NSIndexPath) -> UITableViewCellEdiTingStyle { if (indexPath.row < personnes.count) { return .delete } else { return .None } } override func tableView(tableView: UITableView,editActionsForRowATindexPath indexPath: NSIndexPath) -> [UITableViewRowAction]? { let deleteClosure = { (action: UITableViewRowAction!,indexPath: NSIndexPath!) -> Void in print("delete closure called") self.tableView(tableView,commitEdiTingStyle: .delete,forRowATindexPath: indexPath) } let modifyClosure = { (action: UITableViewRowAction!,indexPath: NSIndexPath!) -> Void in print("More closure called") self.performSegueWithIdentifier("modifPersonne",sender: indexPath) } let deleteAction = UITableViewRowAction(style: .Default,title: "Supprimer",handler: deleteClosurE) let modifyAction = UITableViewRowAction(style: .Normal,title: "Modifier",handler: modifyClosurE) return [deleteAction,modifyAction] } override func tableView(tableView: UITableView,commitEdiTingStyle ediTingStyle: UITableViewCellEdiTingStyle,forRowATindexPath indexPath: NSIndexPath) { switch ediTingStyle { case .delete: // delete in the coreData base personnes.removeATindex(indexPath.row) tableView.deleteRowsATindexPaths([indexPath],withRowAnimation: .FadE) default: break } }
一切都运行正常,但我希望编辑模式只是为了重新排序.我不希望出现红色减号,但我想保持滑动动作.
以上是大佬教程为你收集整理的ios – 允许UITableView重新排序,但不能在编辑模式下删除,并启用滑动删除全部内容,希望文章能够帮你解决ios – 允许UITableView重新排序,但不能在编辑模式下删除,并启用滑动删除所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。