Search code examples
iosuitableviewreorderlist

Reordering rows in tableView while not in editing mode


In my app I have implemented the option to re-order rows, but I am using the default edit button to show the delete button and the three lines icon to move the row. But I have seen an iOS app that allows the user to move rows directly, without need to enter the edit mode. I would appreciate any advice to implement that way to allow re-ordering rows directly, not using the edit mode. Thank you.


Solution

  • You need to implement both

    - (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath
    - (BOOL)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath
    

    and have your table view editing set to YES in order for the reorder controls to show.