Long press to reorder items in a UITableViewController in Swift 3

I recently wanted to add long press to reorder to a new app I’m building, but most of the examples I found online were either in Objective-C or an outdated version of Swift, so I decided I would update this for Swift 3.0.

First, we’ll add a function to create an enlarged snapshot of our cell for us to drag around:

Next, we’ll create a handler, for when there is a long press detected:

Finally, lets add a listener to our tableview inside of viewDidLoad:

This should be the end result:

Leave a Reply

Your email address will not be published. Required fields are marked *