Ios 如何在单击多行时使复选标记出现和消失?

Ios 如何在单击多行时使复选标记出现和消失?,ios,objective-c,uitableview,checkbox,Ios,Objective C,Uitableview,Checkbox,我想要一个表,当您单击不同的行时,它们会获得或丢失一个复选标记,以显示它们被选中或未被选中 当前,我的tableview将允许我选择和取消选择不同的行。但复选标记只会在我点击一个又一个后出现。取消选择时也会发生同样的情况,单击带有复选标记的行,然后单击另一行,复选标记消失 这是我目前的代码: - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath

我想要一个表,当您单击不同的行时,它们会获得或丢失一个复选标记,以显示它们被选中或未被选中

当前,我的tableview将允许我选择和取消选择不同的行。但复选标记只会在我点击一个又一个后出现。取消选择时也会发生同样的情况,单击带有复选标记的行,然后单击另一行,复选标记消失

这是我目前的代码:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString * exerciseChoiceSimpleTableIdentifier = @"ExerciseChoiceSimpleTableIdentifier";
    UITableViewCell * exerciseChoiceCell = [tableView dequeueReusableCellWithIdentifier:exerciseChoiceSimpleTableIdentifier];

    if (exerciseChoiceCell == nil) {
        exerciseChoiceCell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:exerciseChoiceSimpleTableIdentifier];
    }

    //Here we get each exercise we want to display
    BExercise * exercise = [[_data getExerciseCompleteList] objectAtIndex:indexPath.row];

    //Name the cell after the exercises we want to display
    exerciseChoiceCell.textLabel.text = exercise.name;

    return exerciseChoiceCell;
}

    -(void)tableView:(UITableView *)tableView didDeselectRowAtIndexPath:(NSIndexPath *)indexPath {

    if ([tableView cellForRowAtIndexPath:indexPath].accessoryType == UITableViewCellAccessoryNone)
    {
        // Uncheck the row
        [tableView deselectRowAtIndexPath:indexPath animated:YES];
        [tableView cellForRowAtIndexPath:indexPath].accessoryType = UITableViewCellAccessoryCheckmark;
    }
    else
    {
    // Check the row
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    [tableView cellForRowAtIndexPath:indexPath].accessoryType = UITableViewCellAccessoryNone;

    }
}
我认为问题在于它是被选中的,而不是在手指从按钮上松开时在内部进行润色和取消选择

我希望答案非常直截了当,但是关于stackflow的所有类似问题都没有涉及复选标记延迟出现

了解这个问题的根源以及如何解决它会很好

改变方法

   -(void)tableView:(UITableView *)tableView didDeselectRowAtIndexPath:(NSIndexPath *)indexPath 

 -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath