Ios 删除UIView中TableView的记录
我正在尝试在脚本的UIView中实现TableView。 这就是我所取得的成就: 现在我想要编辑按钮,如果按下,准备删除表行。 我将编辑按钮放在工具栏上,显示以下内容:Ios 删除UIView中TableView的记录,ios,uitableview,button,uiview,edit,Ios,Uitableview,Button,Uiview,Edit,我正在尝试在脚本的UIView中实现TableView。 这就是我所取得的成就: 现在我想要编辑按钮,如果按下,准备删除表行。 我将编辑按钮放在工具栏上,显示以下内容: //add edit button [buttons addObject:self.editButtonItem]; 此外,我还将tableview委托和数据源设置为主视图,并触发事件。但是我如何告诉编辑按钮表的行必须是可删除的呢 提前谢谢大家,, yassa有一种委托选项卡视图方法: - (void)tableView:(
//add edit button
[buttons addObject:self.editButtonItem];
此外,我还将tableview委托和数据源设置为主视图,并触发事件。但是我如何告诉编辑按钮表的行必须是可删除的呢
提前谢谢大家,,
yassa有一种委托选项卡视图方法:
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
{
[tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath]
withRowAnimation:UITableViewRowAnimationFade];
//some other bookkeeping stuff
}
添加了按下时编辑按钮的代码。将“toggleEdit”重命名为任何适合您需要的名称
- (IBAction)toggleEdit:(id)sender //this method should get called when Edit is pressed
{
[self.tableView setEditing:!self.tableView.editing animated:YES];
//The if ... else part is optional. You might need to make some change to fit your's.
// if (self.tableView.editing)
// [self.navigationItem.rightBarButtonItem setTitle:@"Done"];
// else
// [self.navigationItem.rightBarButtonItem setTitle:@"Delete"];
}
谢谢你的回答。我已经实现了委托方法。我的问题是我不知道如何在我的视图中将编辑按钮引用到我的表中。。。