views:

214

answers:

1

Hello,

I have a table view with custom cells and I recognize swipes in that cells. That works just fine but I'd like the table view to behave normally. When I tap the wherever on the table view I'd like cell to get selected and perform action tableView:didSelectRowAtIndexPath:

Any tips or ideas?

Thanks.

A: 

I assume you are implementing the various UIResponder methods in your UITableView cell subclass. If you want the rest of the stack to continue processing the events you can just pass them on:

- (void) touchEnded:(UITouch *)touch withEvent:(UIEvent *)event {
   //do something with touch
   //...

   //pass the event to super which cause it to continue along the chain as
   //though you didn't do anything special with it
   [super touchEnded:touch withEvent:event];
}
Louis Gerbarg
I tried your solution but still nothing.... I also tried self.superview in cell touchEnded but with the same result, without actually
Marcin Zbijowski
Well, the exact details depend on the exact layout of the hierarchy. I suppose you go directly forward the touch to the appropriate object, but it might just forward it back to you. You might need to manually invoke -selectRowAtIndexPath:animatedscrollPosition:scrollPosition: from inside the cell.
Louis Gerbarg
After further reading of Apple's documentation I get it working. Your original solution was just right but I had to add calls to super object not just in touchEnded. When I added those calls to touchBegan, toucheMoved and touchCancelled tableview started to behave as expected. Thank you.
Marcin Zbijowski