Is it possible to use iOS 11 Drag and Drop to reorder multiple items/cells at a time in UITableView?

后端 未结 3 1357
借酒劲吻你
借酒劲吻你 2021-01-05 05:45

I know it\'s possible to reorder a single item/cell at a time when using the new UITableViewDropDelegate and UITableViewDragDelegate delegates but

3条回答
  •  礼貌的吻别
    2021-01-05 06:26

    It's possible to do multi-row reordering yourself by providing references to all the selected cells via your drag delegate (e.g. an array of section.row's ) then implementing tableView:performDropWith:withCoordinator to reorder them. (I suspect you know this)

    If you want to support reordering by returning a drop proposal of UITableViewDropProposal(operation: .move, intent: .insertAtDestinationIndexPath) so UIKit uses the pre-iOS 11 tableView:moveRowAt:to function then this only supports a single row.

    Table view moveRowAt IndexPath to IndexPath. You can continue to implement this, if you like, to support reordering, using Drag and Drop. Because table view is actually going to call this instead of calling through perform drop with coordinator, if you've returned that magic drop proposal and a single row is actually being reordered.

    Source: https://developer.apple.com/videos/play/wwdc2017/223/?time=1836

提交回复
热议问题