iOS UITableViewCellAccessoryCheckmark Visible ob every scroll

后端 未结 4 1154
甜味超标
甜味超标 2021-01-28 02:50

I have a list which I have using as a check boxes. I have enable or disable Check mark on row on select. But when I scroll the list its make mark row after every 10 rows.

<
4条回答
  •  执笔经年
    2021-01-28 03:03

    - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
    {
    
        UITableViewCell *selectedCell = [tableView cellForRowAtIndexPath:indexPath];
    
        if ([selectedCell accessoryType] == UITableViewCellAccessoryNone) {
    
            [selectedCell setAccessoryType:UITableViewCellAccessoryCheckmark];
    
            [NSMutableArray addObject:[AnotherMutableArray objectAtIndex:indexPath.row]];
    
        } else {
    
            [selectedCell setAccessoryType:UITableViewCellAccessoryNone];
    
           [NSMutableArray removeObject:[AnotherMutableArray objectAtIndex:indexPath.row]];
    
        }
        [tableView deselectRowAtIndexPath:indexPath animated:NO];
    }
    

    Also in your viewDidLoad, instantiate you both mutable arrays-

    yourmutableArray1 = [[NSMutableArray alloc]init];
    yourmutableArray2 = [[NSMutableArray alloc]init];
    

提交回复
热议问题