0

I have a UITableiew that I want to be able to display a custom check mark when the row is selected (tapped), however, if there is a check mark on any of the other rows, it must be hidden. What is the best way to do this? The IF... doesn't seem to work at all, it will not hide and unhide the check mark as I thought it would.

Thanks in advance. -PaulS.

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{    
    home_2_CustomCell *cell = (home_2_CustomCell*)[tableView cellForRowAtIndexPath:indexPath];

    //This will hide the selected row...
    cell.imageViewDidSelectRow.hidden = YES;

//    if (cell.imageViewDidSelectRow.hidden = NO){
//        cell.imageViewDidSelectRow.hidden = YES;
//    }

}
Paul S.
  • 1,342
  • 4
  • 22
  • 43
  • Found the answer here: http://stackoverflow.com/questions/5959950/iphone-uitableview-cellaccessory-checkmark – Paul S. Mar 13 '12 at 01:57

2 Answers2

0

You can get the each cell of tableview by this code UITableViewCell *cell=[product_table cellForRowAtIndexPath:[NSIndexPath indexPathForRow:clickedTag inSection:0]]; make one for loop.

for(int i=0;i<[tabledata count];i++){
cell.imageViewDidSelectRow.hidden = YES; 
}

for each cell except the current row which is selected and you got only one image displayed for the current row.

Banker Mittal
  • 1,918
  • 14
  • 26
0
1) Maintain a tag in class level as an NSIndexPath variable. 
2) Whenever a cell is selected make note of the indexPath and reload the table view. 
3) In cellForRowAtIndexPath delegate check for this variable and set marks accordingly.
4) This will not be costly if you have the cell with less information.
cocoakomali
  • 1,346
  • 1
  • 8
  • 7
  • Since all the data is apart of my Core Data entities, would it make sense to track it in Entity as a new BOOL attribute, and then parse through the values, modifying the objects as the rows are selected? – Paul S. Mar 12 '12 at 19:27