简体   繁体   中英

Recognize two touches tap on two different subviews

I want to handle in superview a touch event when there are two touches that land on different subviews.

Can I do it somehow by adding UITapGestureRecognizer with numberOfTouchesRequired =2; with a target self to a subviews?

Or I need to go something more complicated?

You could try something like this:

- (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
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM