Alex Rivera | Logout

UITableView tap to deselect cell

Asked 2012-10-02T15:28:28.220
27

I have a UITableViewCell that is selected when tapped. During this selected state, if the user taps the cell again, I want the cell to deselect.

I can't find any of the delegate calls being hit. Any ideas how to implement this? Is it really going to be a gesture recognizer?

Edit
Report

1 Answer

3

When you select a cell this delegate method is triggered.

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


        UITableViewCell *theUITableViewCell = [tableView cellForRowAtIndexPath:path];
        if (theUITableViewCell.selected == YES){
            self.tableView deselectRowAtIndexPath:<#(NSIndexPath *)#> animated:<#(BOOL)#>
            // Do more thing
        }else{
            // By default, it is highlighted for selected state
        }

 }

It's pseudo code.

answered 2012-10-02T15:49:44.883

Your Answer