When I select a row from a UITableView, that row and others below (several rows below the one selected) are also selected. Only the selected row is expected to be the selected one.
My code is:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
if (cell.accessoryType == UITableViewCellAccessoryCheckmark) {
//Deselect
cell.accessoryType = UITableViewCellAccessoryNone;
cell.backgroundColor=[UIColor clearColor];
} else {
//Select
cell.accessoryType = UITableViewCellAccessoryCheckmark;
cell.backgroundColor=[UIColor redColor];
}
}
Thanks in advance!
Yes, you have to declare a new
NSMutableArray(say_selectedList) of your datasource count. Populate it with NSNumber with value 0.Declare
NSMutableArray *_selectedList;in .h file (as class member)In
viewDidLoadorinitmethod,And make the following methods as follows.