在UITableView中编辑模式

时间:2011-01-08 10:19:33

标签: iphone objective-c iphone-sdk-3.0 uitableview

所以我实现了

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

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

但是如何触发将tableview切换到编辑模式的东西?与单击编辑时iphone中的消息一样,将显示删除图标。这可能听起来非常基本,但我对此毫无头绪并且有点紧急,任何线索都会受到赞赏,谢谢。

2 个答案:

答案 0 :(得分:5)

[tableView setEditing:YES animated:YES];

答案 1 :(得分:2)

您还可以使用导航控制器并在其中加载表格视图。然后只需在左侧导航栏项目中指定一个编辑按钮,它就会为您切换编辑。

// in the table viewDidLoad

self.navigationItem.rightBarButtonItem = self.editButtonItem;
相关问题