I need to add haptic feedback in a table view when the user tries to rearrange the cells via dragging and dropping them, but whenever they pass through a cell, even if they don’t drop it there, it still needs to generate a haptic. please help. Thanks in advance.
I tried overriding various tableView methods, and did get an haptic on lifting the cell and while dropping it. I need something that whenever the highlighted item passes through a cell, even if the user doesn't drop it there, it still needs to generate a haptic, which is where I’m stuck.
UITableViewDropDelegatehas a method that can inform you while the drag is taking place:From Apple's docs:
So, we could add an
IndexPath"tracking" property to our controller:then, assuming we've setup a
UIImpactFeedbackGenerator(I called minedropTargetChangedHapticGenerator), implement something like this inUITableViewDropDelegate:Probably also want to set
currentDestinationIndexPath = nilafter the drop has completed.Note: I based this on the sample app available from Apple here: Adopting Drag and Drop in a Table View