13

I wanted to find out how to do the following:

I have a UItableView, which enters edit mode when the user taps and holds one of the rows

Once it enters edit mode I need the cell to remain selected and give the effect of popping out, under the users finger.

The user should be able to drag the popped out cell and reposition it to another row, without lifting the finger.

What I already have in place:

I have a long tap gesture recognizer and I set the table into editing in the long tap gesture recognizer selector.

However in order to drag the cell I currently require to raise the finger and re tap to drag the cell , which is not what I want.

Any help would be appreciated.

kukushkin
  • 209
  • 1
  • 3
  • 6
  • possible duplicate of [Reordering UITableView without reorder control](http://stackoverflow.com/questions/5624730/reordering-uitableview-without-reorder-control) – Senseful Jul 03 '14 at 00:38
  • The better code snippet is here: see https://github.com/bvogelzang/BVReorderTableView. (Tested in Xcode 6.x and iOS 8) – SwiftArchitect Sep 20 '13 at 19:24

2 Answers2

1

The article Reordering a UITableViewCell from any touch point discusses this exact scenario.

Essentially you do the following:

  1. Find the UITableViewCellReorderControl (a private class).
  2. Expand it so it spans the entire cell.
  3. Hide it.
  4. The user will now be able to drag the cell from anywhere.

Another solution, Cookbook: Moving Table View Cells with a Long Press Gesture, achieves the same effect by doing the following:

  1. Add a long press gesture recognizer on the table view.
  2. Create a snapshot of the cell when the cell is dragged.
  3. As the cell is dragged, move the snapshot around, and call the -[UITableView moveRowAtIndexPath:toIndexPath:].
  4. When the gesture ends, hide the cell snapshot.
Senseful
  • 86,719
  • 67
  • 308
  • 465
0

At current moment there is a workaround (not easy enough): https://stackoverflow.com/a/7501076/326017 .

And I have found code snippet here: https://github.com/FlorianMielke/FMMoveTableView

"FMMoveTable is an UITableView subclass that provides moving rows by simply tap and hold an appropriate row without switching the table to it's edit mode" - from description

Community
  • 1
  • 1
brigadir
  • 6,874
  • 6
  • 46
  • 81