简体   繁体   中英

In tableview, if select section 1 row 1 then why is second section row 1 selected also?

I used a cell tapped method with check button. If I select the first section and first row then it automatically selects the second section first row. Meaning if you select any row then it is selecting the same row in another section. I don't understand why.

I also tried section condition ( indexpath.section ==0 ) or something another section condition. I have two arrays so I take manually 2 section and row will depend on the condition.

if(section ==0) { return arra1.count } else { return arr2.count }

Previously I followed this implementation.

选择第一部分 1 行

另请参阅选择第二部分同一行?

Finally resolve my problem. i just take two indexset array. if checkbutton tap by first section than i store addindex in nsmutable indexset arr1 and same thing for second section after that i check condition

if ([self.arr1 containsIndex: indexPath.row]) {
         [self.arr1 removeIndex: indexPath.row];
     } else {
         [self.arr1 addIndex:indexPath.row];
     }
       [_tblVScene reloadRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationAutomatic];

if ([self.arr2 containsIndex: indexPath.row]) {
         [self.arr2 removeIndex: indexPath.row];
     } else {
         [self.arr2 addIndex:indexPath.row];
     }
       [_tblVScene reloadRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationAutomatic];

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM