canMoveRowAtIndexPath doesn't get called - but canEditRowAtIndexPath does

ios, iphone, uitableview

Solution

Sorry, the issue is answered here:

Reorder control isn't displayed on table view

You have to also implement

- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)sourceIndexPath toIndexPath:(NSIndexPath *)destinationIndexPath 

Swift:

func tableView(_ tableView: UITableView, canMoveRowAt indexPath: IndexPath) -> Bool {
    return true
}

func tableView(_ tableView: UITableView, moveRowAt sourceIndexPath: IndexPath, to destinationIndexPath: IndexPath) {
    //code
}

Problem

Very very basic. I don't understand. When the table loads and when Edit is toggled `canEdit` is called, but not `canMove`. What am I doing wrong? ``` - (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath { NSLog(@"canEdit=%d", indexPath.row); // output is as expected, "canEdit" for each row return (indexPath.section == 1) ? YES : NO; } - (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath { NSLog(@"canMove=%d", indexPath.row); // nothing. No output return (indexPath.section == 1) ? YES : NO; } ``` Thanks!

Original source