2011-01-08 90 views
3

所以我已經實現了編輯模式中的UITableView

- (BOOL)tableView:(UITableView *)tableView 
canEditRowAtIndexPath:(NSIndexPath *)indexPath 

- (void)tableView:(UITableView *)tableView 
commitEditingStyle:(UITableViewCellEditingStyle)editingStyle 
forRowAtIndexPath:(NSIndexPath *)indexPath 

但如何將我的東西觸發切換實現代碼如下到編輯模式?當您點擊編輯時,就像iphone中的消息一樣,出現刪除圖標。這可能聽起來很基本,但我不知道這個和它有點緊急,任何線索將不勝感激,謝謝。

回答

5
[tableView setEditing:YES animated:YES]; 
+0

非常感謝! :) 非常感謝!!我對快速和正確的迴應感到非常高興。最好的祝願! – 2011-01-08 10:41:20

2

您還可以使用導航控制器並在其中加載您的表格視圖。然後,只需將編輯按鈕分配給左側導航欄項目,它就會爲您切換編輯。

// in the table viewDidLoad 

self.navigationItem.rightBarButtonItem = self.editButtonItem;