Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cells ordering gets messed up when dragging one cell quickly. #11

Open
aksh1t opened this issue Oct 20, 2014 · 4 comments · May be fixed by #14
Open

Cells ordering gets messed up when dragging one cell quickly. #11

aksh1t opened this issue Oct 20, 2014 · 4 comments · May be fixed by #14
Labels

Comments

@aksh1t
Copy link

aksh1t commented Oct 20, 2014

Hi hpique, thanks a lot for this wonderful tableview. While playing around with the demo app, I found a pretty serious bug... I have made gif demonstrating the same.

temp

When I long press on a cell and then move it around very quickly (in both directions - up and down), the ordering of the other cells gets messed up.

For example, in the gif above, look at the cell 4. It gets stuck to the cell that I am currently dragging around. And when I leave the cell 1, a blank space is found where actually the cell 4 should have been.

Also, when dragging the cell over long distance (in both directions, quickly), the ordering of other cells in the table view gets haphazard. If this bug is difficult to reproduce, please do ask to clarify, I'll be happy to make other gifs with more detailed description to sort this bug out.

Thanks again, hpique!

@hpique hpique added the bug label Dec 21, 2014
@operatordevelopment
Copy link

Also seeing this problem. hpique or aksh1t did you have any leads code-wise where things are going wrong?

@bok-
Copy link

bok- commented Mar 30, 2015

It looks to be the ordering of the call to -[UITableView moveRowAtIndexPath:toIndexPath:] that causes this, swapping it back fixes it for me:

diff --git a/HPReorderTableView/HPReorderTableView.m b/HPReorderTableView/HPReorderTableView.m
index b7d3fc7..5709fb4 100644
--- a/HPReorderTableView/HPReorderTableView.m
+++ b/HPReorderTableView/HPReorderTableView.m
@@ -296,7 +296,7 @@ static void HPGestureRecognizerCancel(UIGestureRecognizer *gestureRecognizer)
 - (void)reorderCurrentRowToIndexPath:(NSIndexPath*)toIndexPath
 {
     [self beginUpdates];
-    [self moveRowAtIndexPath:toIndexPath toIndexPath:_reorderCurrentIndexPath]; // Order is important to keep the empty cell behind
+    [self moveRowAtIndexPath:_reorderCurrentIndexPath toIndexPath:toIndexPath];
     if ([self.dataSource respondsToSelector:@selector(tableView:moveRowAtIndexPath:toIndexPath:)])
     {
         [self.dataSource tableView:self moveRowAtIndexPath:_reorderCurrentIndexPath toIndexPath:toIndexPath];

Not submitting a pull request for this as the order appears to be deliberately set that way (59f025c) to work around another issue, which I can't test for.

-bok

@bok-
Copy link

bok- commented Apr 1, 2015

So my patch above does re-introduce the behaviour I think 59f025c was supposed to fix; that is, the cell being moved moves on top of the other cells. I fixed that by setting the cell layer's zPosition on dequeue so that won't happen and now both bugs appear to be fixed:

        cell.layer.zPosition = -10;

I'll pop in a pull request shortly.

@bok- bok- linked a pull request Apr 1, 2015 that will close this issue
@AlmightyCZ
Copy link

Quick drag also causes call of - (void)tableView:(UITableView*)tableView moveRowAtIndexPath:(NSIndexPath*)sourceIndexPath toIndexPath:(NSIndexPath*)destinationIndexPath with a row difference greater than one which is fine if the data source implementation "knows" that, but example implementation from title page (exchangeObjectAtIndex) leads to inconsistencies in underlying array.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants