开发者

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开发者_如何学C 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?


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.


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].


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜