Search code examples
iosuitableviewcocoa-touch

Why does UITableViewCell remain highlighted?


What would cause a table view cell to remain highlighted after being touched? I click the cell and can see it stays highlighted as a detail view is pushed. Once the detail view is popped, the cell is still highlighted.


Solution

  • In your didSelectRowAtIndexPath you need to call deselectRowAtIndexPath to deselect the cell.

    So whatever else you are doing in didSelectRowAtIndexPath you just have it call deselectRowAtIndexPath as well.

    - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
     // Do some stuff when the row is selected
     [tableView deselectRowAtIndexPath:indexPath animated:YES];
    }