Enable dragging UITableViewCell without setEditing method:

I am trying to enable drag and drop UITableViewCell to replace them. This is not a problem, but I want to do it without the setEditing: method. I want to swap cells before dragging the cell with something like longGestureAction and drop it elsewhere, but without disabling the selectRow method and no icons on the side.

I don't need something like this:

1img http://dl.dropbox.com/u/10739464/stackoverflow/bad.png

I want something like this / with the ability to drag and drop of course /:

2img http://dl.dropbox.com/u/10739464/stackoverflow/good.png

Oh, I need to enable drag and drop, like in the Clear app.


source to share

2 answers

You can easily get this efect with -setEditing:

. You just need to assign some properties to yours UITableViewCells


- (UITableViewCell*)tableView:(UITableView)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

    UITableViewCell *cell = ...;

    cell.shouldIndentWhileEditing = NO;
    cell.showsReorderControl = NO;

    return cell;



Just make sure you call -setEditing:

in -viewDidLoad


- (void)viewDidLoad {
    [tableView setEditing:YES animated:NO];


EDIT: I searched the web a bit and found this: JTGestureBasedTableViewDemo for iOS . It's ClearApp-based and very impressive. You can see how to do this and apply some solutions in your application :)

EDIT # 2: If you want to enable selection while editing, just set this tableView property:

tableView.allowsSelectionDuringEditing = YES;




You can try this: https://github.com/ice3-software/i3-dragndrop and this stack over streaming channel: drag from uitableviewcell to uiimage view in ios

(For the above library, you can try using 1st example.)

I would have liked to write this more as a comment ... but I don't have enough reputation.

Hope this helps someone.



All Articles