iPhone: detect two finger touch

后端 未结 3 1557
独厮守ぢ
独厮守ぢ 2021-02-15 14:28

I need to detect two finger touch event. If i touch the screen with two fingers on same time, so everthing is ok. Just using such code:

- (void)touchesBegan:(NSS         


        
3条回答
  •  萌比男神i
    2021-02-15 15:19

    - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
    {
        UITouch *touch1, *touch2;
        CGPoint    location1, location2;
    
        NSSet *allTouches = [event allTouches];
        touch1 = [[allTouches allObjects] objectAtIndex:0];
        location1 = [touch1 locationInView:self];
    
        if([allTouches count] > 1)
        {
            touch2 = [[allTouches allObjects] objectAtIndex:1];
            location2 = [touch2 locationInView:self];
        }
    }
    

提交回复
热议问题