6

UITableViewに設定allowsMultipleSelectionDuringEditingして、いくつかの行を削除しようとしていYESます。これはすべてうまく機能しています。左側に円が表示されています。

ただし、特定のセルでは、左側の円が表示されないようにします。それ、どうやったら出来るの?cell.selectionStyle = UITableViewCellSelectionStyleNone編集中に試してみましたが、うまくいきませんでした。

ヒントはありますか?

4

3 に答える 3

3

複数の選択から一部の行を禁止するには、を組み合わせて使用​​する必要があり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;
    }
}
于 2012-10-10T17:40:53.960 に答える
-1

のメソッドを実装して、削除コントロールを表示したくないセルにtableView:editingStyleForRowAtIndexPath: UITableViewDelegate戻ることを試みましたか?UITableViewCellEditingStyleNone

于 2012-07-08T20:15:01.850 に答える