Implementing iOS 11 Drag and Drop in a table view. If I don't want the first row to be dragged, I assume I return an empty array from tableView(:itemsForBeginning:)
func tableView(_ tableView: UITableView, itemsForBeginning session: UIDragSession, at indexPath: IndexPath) -> [UIDragItem] {
if indexPath.row == 0 {
return []
}
let dragItems = self.dragItems(forRowAt: indexPath)
print("dragging row index \(String(describing: dragItems.first?.localObject as? Int))")
return dragItems
}
Return an empty array when you do not allow the user to drag content from the specified index path.
But even when it's verified that [ ] is returned, the drag still happens. That means either I screwed up or the feature is not implemented as documented. I'm always hesitant to think it's someone else, so my question is if the return of [ ] as implemented should in fact prevent the drag of the 0 row? Anyone else verify this or show it as working as documented?
Thanks
Edit: Sample code from WWDC video includes this chunk:
if tableView.isEditing {
// User wants to reorder a row, don't return any drag items. The table view will allow a drag to begin for reordering only.
return []
}
Is this saying that if you don't return any drag items, the table view will still allow dragging?!?! Then how would one prevent a row from being dragged at all?