ios – UITableView的allowMultipleSelectionDuringEditing – 不显示某些单元格的编辑圈

前端之家收集整理的这篇文章主要介绍了ios – UITableView的allowMultipleSelectionDuringEditing – 不显示某些单元格的编辑圈前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我试图通过将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;
    }
}

猜你在找的iOS相关文章