2013-03-19 69 views
1

我有一个表。当我在表格单元格中水平滑动时,会出现一个按钮,询问我是否要删除该行。表行交换时删除

我不想要那个功能。不过,我上下查看了代码,并且从未看到此功能在哪里实现。

其他表上的其他行不具有相同的行为。

回答

1

我想你想要做的是:

- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    // Return NO if you do not want the specified item to be editable. 
    return NO; 
} 
在表中的的viewController

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; 
} 
1

不过,我抬头一看代码上下,我从来没有看到它实现了此功能。

它由表视图实现。您可以通过从表格数据源的实现-tableView:canEditRowAtIndexPath:返回NO来防止单元格被编辑,并且您可以通过从-tableView:editingStyleForRowAtIndexPath:返回适当的值来更改给定行的可用编辑选项。