2012-07-08 86 views

回答

-1

您是否尝试过实施tableView:editingStyleForRowAtIndexPath: UITableViewDelegate的方法,并返回UITableViewCellEditingStyleNone以表示您不想显示删除控制的单元格?

+1

是我没有,但这种方法是没有得到调用。 – Herman 2012-07-09 20:07:32

+0

编辑期间启用多项选择时,不会调用editingStyleForRowAtIndexPath。 – shim 2015-08-25 21:09:03

2

为了不允许多行选择您应该使用tableView:shouldIndentWhileEditingRowAtIndexPath:混合cell.selectionStyle = UITableViewCellSelectionStyleNone

这里是从我的代码示例:

- (BOOL)tableView:(UITableView *)tableView shouldIndentWhileEditingRowAtIndexPath:(NSIndexPath *)indexPath*)indexPath { 
    if (indexPath.row < 4) { 
     return YES; 
    } else { 
     return NO; 
    } 
} 

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { 
    // (...) configure cell 

    if (indexPath.row < 4) { 
     cell.selectionStyle = UITableViewCellSelectionStyleBlue; 
    } else { 
     cell.selectionStyle = UITableViewCellSelectionStyleNone; 
    } 
}