我有一张桌子。当我在表格单元格中水平滑动时,会出现一个按钮,询问我是否要删除该行。
我不想要这个功能。但是,我上下查找代码,我从未看到此功能在何处实现。
其他表上的其他行的行为方式不同。
答案 0 :(得分:1)
我认为你想要做的是:
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath
{
// Return NO if you do not want the specified item to be editable.
return NO;
}
在你的表的viewController中。
答案 1 :(得分:1)
但是,我上下查找代码,我从未看到此功能的实现位置。
它由表视图实现。您可以通过从表数据源的-tableView:canEditRowAtIndexPath:
实现返回NO来防止对单元格进行编辑,并且可以通过从-tableView:editingStyleForRowAtIndexPath:
返回适当的值来更改给定行的可用编辑选项。
答案 2 :(得分:0)
- (UITableViewCellEditingStyle)tableView:(UITableView *)aTableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath {
// Detemine if it's in editing mode
if (self.editing) {
return UITableViewCellEditingStyleDelete;
}
return UITableViewCellEditingStyleNone;
}
或
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath {
return NO;
}