检测自定义UIViewController中的多点触控包含UITableView子视图

时间:2011-11-17 03:58:48

标签: ios uitableview uiviewcontroller multi-touch

我在UIViewController的视图中有一个UITableView作为子视图。我知道我可以通过覆盖来检测触摸事件

-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
    [super touchesBegan:touches withEvent:event];
}

-(void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{
    [super touchesEnded:touches withEvent:event];
}

-(void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event
{
    [super touchesCancelled:touches withEvent:event];
}
-(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
{
    [super touchesMoved:touches withEvent:event];  
}

但如果我触及ViewController,它就不会在tableview中检测到这些事件。正如其他人在本论坛中所建议的那样,我应该有一个自定义UITableView并在其中添加上述行。我做到了,但viewController仍未检测到触摸事件。有什么建议?感谢。

1 个答案:

答案 0 :(得分:1)

经过几天的谷歌搜索,我终于找到了适合我的解决方案。关键是将响应者链传递给下一个响应者。例如,在触摸开始的情况下,添加以下行。 [self.nextResponder touchesBegan:touches withEvent:event]