I want to enable drag and drop in tableview. I only want to drag items in app and I don't want it to be transferred to other app.
I found two ways to implement tableview rearrangement.
First way: use drag and drop delegate
drag delegate documentation supporting drag and drop in tableview in iOS11
It is realy important for me not to allow drag and drop between apps.
Is using drag delegate ok in this situation? Or should I use another solution?
// didLoad
[self.myTableView setDragDelegate: self];
[self.myTableView setDragInteractionEnabled: YES];
// itemsForBeginningDragSession
(NSArray<UIDragItem *> *)tableView:(UITableView *)tableView
itemsForBeginningDragSession:(id<UIDragSession>)session
atIndexPath:(NSIndexPath *)indexPath API_AVAILABLE(ios(11.0)) {
Model *model = self.listOfX[indexPath.section];
NSItemProvider *itemProvider = [[NSItemProvider alloc] initWithObject: model];
UIDragItem *dragItem = [[UIDragItem alloc] initWithItemProvider: itemProvider];
return @[dragItem];
}
second way: tableview edit mode
[self.myTableView setEditing: YES];
I don't want to add a button and change the table view state to editing mode. I want to enable rearrangement by long press.