我试图通过将allowsMultipleSelectionDuringEditing设置为YES来删除我的UITableView中的一些行.这一切都运作良好;圆圈显示在左侧.
但是,对于某些细胞,我不希望左侧的圆圈出现.我怎么做?我在编辑过程中尝试过cell.selectionStyle = UITableViewCellSelectionStyleNone,但是没有用.
任何提示?
解决方法
为了禁止多个选择中的某些行,您应该使用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; } }