我有一个视图,它有自己的导航栏和一个表格视图。我想在该表视图中编辑和删除项目。我已经像这样在导航栏上放置和编辑按钮。
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 中的所有项目都没有带有该红色标记图标。只是编辑按钮的标题更改为“完成”。
应该是什么问题?