Search code examples
objective-ciosuitableviewtouchesbegan

Receive TouchesBegan of UITableViewCell in UIViewController


How can I receive TouchesBegan from a UITableViewCell in a UITableViewController so I can know when the user touches some cell?


Solution

  • When you touch the a cell, it becomes highlighted; try overriding setHighlighted: in a subclass of UITableViewCell to adjust your appearance when it changes to YES (user touching) or NO (user lifted off).

    (Overriding touchesBegan:withEvent: will also work, but it's easier to use setHighlighted: in order to capture when you're not longer touching; otherwise you need to override touchesEnded:withEvent: and touchesCancelled:withEvent:).