[英]UITableViewCell Does not respond to the responder chain
我在开发过程中遇到问题,我有一个UITableViewCell
,它添加了一个UIButton
( UIButton
充满了Cell),希望我的UIButton
响应我的touchupinside
事件,在处理完成后,该事件再次发送touchupinside
,直到Cell到响应didSelectRowAtIndexPath
方法。但是现在, didSelectRowAtIndexPath
没有起作用吗? (注:我不想手动调用didSelectRowAtIndexPath
方法,希望通过响应者链来解决这个问题)
如果按钮比单元格小,它将按预期工作:如果触摸按钮,则按钮处理程序将触发,如果触摸单元格中的另一个区域,则didSelectRowAtIndexPath
触发。
但是,如果按钮覆盖整个单元格,则不是问题。 您可以从按钮处理程序调用与表视图委托相同的例程。
- (void)tableView:(UITableView *)tableView
didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
[self doCellThingWithIndexPath:indexPath];
}
- (void)buttonAction:(UIButton*)sender {
// do whatever the button does, then
CGRect buttonFrame = [button convertRect:sender.bounds toView:self.tableView];
NSIndexPath *indexPath = [self.tableView
indexPathForRowAtPoint:buttonFrame.origin];
[self doCellThingWithIndexPath:indexPath];
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.