In the @interface
that implements the UITableViewDataSource (geralmente o
view controller associated with the table), you need to implement the selector tableView:moveRowAtIndexPath:toIndexPath:
. In the implementation you need to change the order of your elements NSMutableArray
, as in the example below:
- (void) tableView:(UITableView *)tableView
moveRowAtIndexPath:(NSIndexPath *)sourceIndexPath
toIndexPath:(NSIndexPath *)destinationIndexPath
{
NSInteger fromIndex = sourceIndexPath.row;
NSInteger toIndex = destinationIndexPath.row;
if (fromIndex == toIndex) return;
id item = [self.items objectAtIndex:fromIndex];
[self.items removeObjectAtIndex:fromIndex];
[self.items insertObject:item atIndex:toIndex];
}
Carlos I had something similar to what you presented. But I will test your code and report the result!
– Tiago Amaral