iOS 11 Drag and Drop with Table and Collection Views | Ray Wenderlich

In this screencast, you'll learn the basics of adding iOS 11's new drag and drop support into your iOS apps, starting with table and collection views.


This is a companion discussion topic for the original entry at https://www.raywenderlich.com/5017-ios-11-drag-and-drop-with-table-and-collection-views

Outstanding, Ray! In my opinion, this is a better and much clearer intro to using Drag and Drop with UITableView than was presented at WWDC. Your tutorials are the best - thatā€™s why Iā€™ve been a long-time subscriber. I look forward to your next screencast!

Thank you for the super kind note @cdisdero - it made my day! :]

Great tutorial Ray! Very nice to have drag and drop tutorials out there already!! Anyways, Iā€™ve implemented pretty much the same code on my performDropWith coordinator for reorderring my colletion view, but when I release my dragged item at the destinationIndexPath my sourceIndexPath blinks, Is this the normal behaviour? Thanks!

I think thereā€™s a piece missing in the first part of this video. It didnā€™t work for me until I set the table viewā€™s drag interaction property. I donā€™t recall hearing it/seeing it in his code example.

tableView.dragInteractionEnabled = YES;

It took a minute for me to figure out why it wasnā€™t working the first time Ray says run the program and it should work. (3:23)

Hi @rwenderlich ,

Is there a way to control the sensitivity of when the drag gesture starts? Drag of an item sometimes starts in a collection view when the user is actually trying to just scroll. How to go about fixing it?

Thanks!

Sorry for the very late question, but getting an error ā€œAmbiguous reference to member ā€˜drop(_:to:)ā€™ā€ in the PetsViewController.swift file at:
let context = coordinator.drop(item.dragItem, toPlaceholderInsertedAt: destinationIndexPath, withReuseIdentifier: "PetCell", rowHeight: 110, cellUpdateHandler: { cell in cell.textLabel?.text = "Loading..." })

This may be a problem with Swift 5, but Appleā€™s documentation still references it as in the screenCast. Any help greatly appreciated!

@sbolin Please check out this WWDC talk when you actually get a chance after all:

https://developer.apple.com/videos/play/wwdc2017/223/

I hope it definitely helps!