Denis Kharitonov Denis Kharitonov - 1 month ago 10
iOS Question

Can't reorder rows in UITableView

I have encountered an issue when trying to reorder rows in

UITableView
.
I have the function
tableView:moveRowAtIndexPath:toIndexPath:
triggered, but
fromIndexPath
is equal to
toIndexPath
(i.e. source == destination).
I saw the same issue here: uitableview re-order won't work, source always equal to destination
But the solution was - to use different library. That is not a variant for me.

- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath {
//fromIndexPath is equal to toIndexPath, so nothing is exchaned
[self.table_data exchangeObjectAtIndex:fromIndexPath.row withObjectAtIndex:toIndexPath.row];
}


My table is in editable mode, I have
canMoveRowAtIndexPath:
returning
YES
. My it does not help.
How come? What am I doing wrong?

Answer

The problem was in custom pan gesture recognizer. It somehow was in conflict with rows drag-drop behavior

Setting myGestureRecognizer.cancelsTouchesInView = NO; fixed the issue

Comments