2011-03-02 38 views
0

我在DataSource類下面的代碼在UITableView上觸發移動?

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

public override void MoveRow (UITableView tableView, NSIndexPath sourceIndexPath, NSIndexPath destinationIndexPath) 
{ 
     ... code for swapping the location of stuff in a list 
    } 

如何觸發「移動」?如果我刷我的UITableView我得到我的刪除按鈕,但我如何得到'移動'?我是否需要放置一個按鈕,然後將表格放入BeginEditting模式?任何示例代碼來做到這一點?

+0

[管理行的重新排序](http://developer.apple.com/library/ios/#documentation/UserExperience/Conceptual/TableView_iPhone/ManageReorderRow/ManageReorderRow.html%23//apple_ref/doc/uid/ TP40007451-CH11-SW1)章節中詳細解釋了這一點。雖然Objective-C中有示例代碼,但它不應該很難轉換。 – Anna 2011-03-02 03:33:20

回答

1

爲了讓表格能夠執行移動操作,需要將表格設置爲「編輯」模式(tableView.Editing = true;)。

相關問題