适用于 Swift 3 和 Swift 4
使用UITableViewDataSource
tableView(:commit:forRowAt:)方法
func tableView(_ tableView: UITableView, commit editingStyle: UITableViewCellEditingStyle, forRowAt indexPath: IndexPath) { if editingStyle == .delete { print("Deleted") self.catNames.remove(at: indexPath.row) self.tableView.deleteRows(at: [indexPath], with: .automatic) }}


