Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Reordering rows in tableView while not in editing mode [duplicate]

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.

like image 616
mvasco Avatar asked Mar 21 '23 12:03

mvasco


1 Answers

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.

like image 91
mackross Avatar answered Mar 23 '23 12:03

mackross