views:

518

answers:

3

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?

A: 

I don't know answer on your question, but have an offer. You can mark selected row with the checkmark in your

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

delegate method. And then call [tableView deselectRowAtIndexPath:indexPath].

Morion
well... I wasn't clear enought. I apologize.actually in my case there is always one selected cell.the problem is if a cell is selected the second one will have the selected style on touch but it won't be selected.I have already tried this method but didSelectRowAtIndexPath is called when you remove the finger from the cell not when you touch the cell and stay on it.I added a screen shot to show how it looks like.http://img190.imageshack.us/img190/7184/cellsz.jpg
HiroKenshin
I mean that if you only have to mark selected row, you can change its accessoryType to, for example, UITableViewCellAccessoryTypeCheckmark and call deselectRow in that delegate method.
Morion
A: 

There's no framework provided solution to select multiple rows. Morion has a good way to do this with checkmarks. You can also look at this article by Matt Gallagher where his implements what you wants.

gcamp
I don't want multiple cell selection. I wasn't clear I apologize.I want to avoid two cell to have the selected style at the same time. this gives application a real bad look.look at the screenshot I added in my post.
HiroKenshin
A: 

Finally I have success 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.

HiroKenshin