2012-02-29 82 views
2

我目前使用Monotouch.Dialog中概述的高級編輯tableview,它允許用戶刪除以及編輯表格元素的標籤。有沒有一種方法可以豐富桌面視圖以實現類似於屏幕截圖的操作,即更改排序?monodouch DialogViewController元素的更改順序

rearrange order of table elements

回答

4

您需要這兩種方法添加到您的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); 
     } 
+0

謝謝你的作品。我需要做什麼才能在訂單中進行更改?目前,我選擇完成後會回到最初的順序。 MoveRow()中的 – kos 2012-02-29 15:10:57

+0

需要手動對數據源進行必要的更改,以便在重繪表格時正確排序。 – Jason 2012-02-29 16:26:17

+1

MonoTouch.Dialog的示例應用程序(在DemoEditingAdvanced.cs中)已更新以顯示此功能,請參閱:https://github.com/migueldeicaza/MonoTouch.Dialog/commit/62d5008c50ba3f5479c10a553451a6202af8d382#Sample – poupou 2012-03-06 16:06:51