2

I am currently using the advanced editing tableview as outlined in Monotouch.Dialog that allows a user to delete as well as edit the label of table elements. Is there a way to enrich the tableview to achieve something similar to the screenshot, i.e. change the ordering?

rearrange order of table elements

kos
  • 269
  • 3
  • 12

1 Answers1

5

You need to add this two methods to your DialogViewController.Source

        public override bool CanMoveRow (UITableView tableView, NSIndexPath indexPath)
        {
            return true;
        }

        public override void MoveRow (UITableView tableView, NSIndexPath sourceIndexPath, NSIndexPath destinationIndexPath)
        {
            tableView.MoveRow(sourceIndexPath,destinationIndexPath);
        }
Janub
  • 1,594
  • 14
  • 26
  • Thanks that works. What would I need to do to commit the changes in the ordering? Currently once I select done is goes back to the initial order. – kos Feb 29 '12 at 15:10
  • in MoveRow() you need to manually make the necessary changes to your datasource so that when it redraws the table they are ordered correctly. – Jason Feb 29 '12 at 16:26
  • 1
    MonoTouch.Dialog's Sample application (in DemoEditingAdvanced.cs) has been updated to show this feature, ref: https://github.com/migueldeicaza/MonoTouch.Dialog/commit/62d5008c50ba3f5479c10a553451a6202af8d382#Sample – poupou Mar 06 '12 at 16:06