I'm attempting to trigger an event in a subview of a UITableViewCell
, and let it bubble up the responder chain and be handled by a custom UITableViewCell
subclass.
Basically:
SomeView.m (which is a subview of the UITableViewCell
)
[self.button addTarget:nil action:@selector(someAction:) events:UIControlEventTouchUpInside]
SomeCustomCell.m
- (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 someAction:
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 someAction:
method.
What the heck is going on here?
Here's a project that shows it https://github.com/keithnorm/ResponderChainTest Is this expected behavior somehow? I haven't found any documentation stating UITableViewCell's are treated any differently than other UIResponder's.
ContentView->UITableViewCellContentView->UITableViewCellScrollView->TableCell->UITableViewWrapperView->UITableView->View->ViewController->UIWindow->UIApplication->AppDelegate
. I find that byUIResponder * res = sender ; while (res) { res = [res nextResponder] ; NSLog(@"%@", [res class]) ; }
. I will follow the question. – SingbandTableCell
. – Singband