Search code examples
iphoneuitableviewtemplatesselectioncell

UITableView allow two cells to have selected style at the same time


I have created a UItableView using the default Xcode template and configure it to display five rows. I select the first cell on the table. When I select another cell I notice the first one stay selected until I remove my finger from the second one.

sample: http://img190.imageshack.us/img190/7184/cellsz.jpg

I want a cell to become selected on touch not on touch remove. I searched on the net and in apple documentation but I didn't find which method is called when the user touch the screen for selection.

Does anyone have some information about this?


Solution

  • Finally I have succeeded in suppressing this double selection effect.

    A cell becomes selected when the system detect a touch up inside event on it. Before it becomes selected, the cell have a highlight state which appear on touch.

    To resolve this issue I have to override the - (void)setHighlighted:(BOOL)highlighted animated:(BOOL)animated method in my custom UITableViewCell and do nothing in this method.

    This way the table will never have two selected style cells at the same time.

    quote after edit

    This solution is enought for me, but it doesn't resolve my first request to change cell's selection on "touch in" event instead of "touch out" event.

    well... I assume this is impossible. If we had this option we could select a cell when we just wanted to scroll in a tableview.