0

我有一个视图,它有自己的导航栏和一个表格视图。我想在该表视图中编辑和删除项目。我已经像这样在导航栏上放置和编辑按钮。

self.navItem.leftBarButtonItem = self.editButtonItem;

并且也有这样的一种方法。

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

    if(editingStyle == UITableViewCellEditingStyleDelete) {

        //Get the object to delete from the array.
        //Delete the object from the table.
        [self.tblView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];
    }
}

但是,当我单击该按钮时,tableview 中的所有项目都没有带有该红色标记图标。只是编辑按钮的标题更改为“完成”。

应该是什么问题?

4

1 回答 1

0

这是 UIViewController 还是 UITableViewController?它会出现(来自附加代码中的 self.tblView)您正在使用标准 UIViewController。在这种情况下,您必须在您的视图控制器中实现 setEditing:animated: ,而后者又应该在您的表格视图中调用它。

于 2009-10-23T12:45:56.483 回答