Keith Norman Keith Norman - 1 year ago 89
iOS Question

UITableViewCell skipped in responder chain

I'm attempting to trigger an event in a subview of a

, and let it bubble up the responder chain and be handled by a custom


SomeView.m (which is a subview of the

[self.button addTarget:nil action:@selector(someAction:) events:UIControlEventTouchUpInside]


- (void)someAction:(id)sender {
NSLog(@"cool, the event bubbled up to the cell");

And to test why this wasn't working, I've added the
method on the ViewController and the ViewController is the one that ends up handling the event that bubbles up from the table view cell subview, even though the Cell should handle it. I've checked that the Cell is on the responder chain and I've verified that any views on the responder chain both above and below the cell will respond to the event if they implement the

What the heck is going on here?

Here's a project that shows it Is this expected behavior somehow? I haven't found any documentation stating UITableViewCell's are treated any differently than other UIResponder's.

Answer Source

The cell seems to ask its table view for permission. To change that you can of course override

- (BOOL)canPerformAction:(SEL)action withSender:(id)sender
    return [self respondsToSelector:action];

Swift 3:

override func canPerformAction(_ action: Selector, withSender sender: Any?) -> Bool {
    return responds(to: action)
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download