6

こんにちは、テーブル ビュー編集モードでは、didselectrowatindexpath 関数は呼び出されません。これが私のコードです。私のコードに何か問題がありますか?

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath  {
    if (self.tableView.editing == YES)   {
        NSLog(@"now in editing mode");
    }
    else {
        NSLog(@"now in normal mode");
    }
}

- (void)setEditing:(BOOL)editing animated:(BOOL)animated   {
    [super setEditing:editing animated:animated];
    // must be called first according to Apple docs
    [self.tableView setEditing:editing animated:animated];
}

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

- (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath   {
    return UITableViewCellEditingStyleNone;
}

- (BOOL)tableView:(UITableView *)tableView shouldIndentWhileEditingRowAtIndexPath:(NSIndexPath *)indexPath  {
    return NO;
}

助けてください。ありがとう

4

2 に答える 2

19

編集モードで行を選択できるようにするには、このプロパティを設定する必要がallowsSelectionDuringEditingあります。だからそうあるべきだUITableViewTRUE

self.tableView.allowsSelectionDuringEditing=YES;
于 2013-07-15T10:33:08.697 に答える
1

デフォルトで有効になっているとは思いませんが、非編集選択の場合と同様に、編集中に許可する選択を指定する必要があります。必要に応じて、次の 2 つの行のいずれかを使用します。

- (void)viewDidLoad
{
    [super viewDidLoad];

    [self.tableView setAllowsMultipleSelectionDuringEditing:YES];
    [self.tableView setAllowsSelectionDuringEditing:YES];
}
于 2013-07-15T10:33:28.840 に答える