Swift - Reorder UITableView cells

前端 未结 4 1424
悲哀的现实
悲哀的现实 2021-01-04 12:53

I do know that it\'s not too hard to do it in objective C , the problem is I\'m learning Swift by skipping Objective C.

https://developer.apple.com/library/ios/docu

4条回答
  •  时光取名叫无心
    2021-01-04 13:09

    Converted Above Answer methods in Swift 3.0

        // Determine whether a given row is eligible for reordering or not.
        func tableView(_ tableView: UITableView, canMoveRowAt indexPath: IndexPath) -> Bool {
                return true
        }
    
    
        // Process the row move. This means updating the data model to correct the item indices.
        func tableView(_ tableView: UITableView, moveRowAt sourceIndexPath: IndexPath, to destinationIndexPath: IndexPath) {
            let item : Dictionary = arrInterval[sourceIndexPath.row]
            arrInterval.remove(at: sourceIndexPath.row)
            arrInterval.insert(item, at: destinationIndexPath.row)
        }
    

提交回复
热议问题