Question

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.

Était-ce utile?

La 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.

Autres conseils

use moveRowAtIndexPath:toIndexPath: UITableView method

UITableView implements below method.Use it to move rows, or chain them to have some animation of row by row.

- (void)moveRowAtIndexPath:(NSIndexPath *)indexPath toIndexPath:(NSIndexPath *)newIndexPath

read in detail about it in Apple documentation.

Try to load this from end of your -viewDidLoad:

self.editing = NO;
[self editTable:nil];

editTable: is method action of edit button.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top