识别两个触摸点击两个不同的子视图

时间:2012-03-19 11:23:53

标签: ios uigesturerecognizer

当有两个触摸落在不同的子视图上时,我想在superview中处理触摸事件。

我可以通过将UITapGestureRecognizer numberOfTouchesRequired =2;与目标self添加到子视图来以某种方式实现吗?

或者我需要更复杂的事情?

1 个答案:

答案 0 :(得分:0)

您可以尝试这样的事情:

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { 
UITouch *touch = touches.anyObject; 
CGPoint referencePoint = [touch locationInView:self.view]; 

if([touch tapCount] == 2){
       //Test touch coordinates to see if theres one in each view
}