Drag and drop reorder in UITableView not working on iPhone

I have a drag and drop UITableView example working on the iPad for move/reorder, but drags don't initiate on the iPhone (iOS 11 Beta 2).


Relevant code:


<code>

#pragma mark - UITableViewDragDelegate


- (nonnull NSArray<UIDragItem *> *)tableView:(nonnull UITableView *)tableView

itemsForBeginningDragSession:(nonnull id<UIDragSession>)session

atIndexPath:(nonnull NSIndexPath *)indexPath

{

return [self.dataSourceDelegate dragItemsForIndexPath:indexPath];

}


</code>


UITableView delegate reorder methods not implemented (drag and drop handle it).


I thought the iPhone was going to support in-app (but not cross app) drag and drop functionality - mistaken, missing code, or beta not working for iPhone?

Accepted Reply

On iPhone, you need to set the dragInteractionEnabled property of the table or collection view to true if you want to allow drags to begin, as the default value is false.

Replies

On iPhone, you need to set the dragInteractionEnabled property of the table or collection view to true if you want to allow drags to begin, as the default value is false.

If this doesn't work I suggest reporting it as a bug to the Developer team and it will be fixed in the next update.

Thanks you so much, I lost hours on this one. I have an additional question: I tried to implement Drag & Drop with custom views (so not UITableView or UICollectionView) on iPhone and it didn't work. I didn't find a similar property on UIView or anywhere else, so how can I get this to work?

This was very helpful indeed, but what about custom UIViews? In the documentation it says


"Enabling drag and drop for an image view, which this project uses, requires an additional step. You must explicitly enable user interaction, like this: imageView.isUserInteractionEnabled = true"


I tried to do the same in my UIButton but it doesn't work.Is there anything I need to enable to be able to drag and drop custom UIViews in the iPhone?

Try the solution in this thread: https://forums.developer.apple.com/thread/83220