使用三根手指触发触摸取消

时间:2011-11-22 18:18:37

标签: ios iphone touch-event touchescancelled

我有一个简单的应用程序,可以打印所有触摸事件的坐标。 在模拟器中它很有效。

在我的设备(iPhone)上,它最适合,最多两个手指。当我用快速序列中的三根手指点击时,会触发事件touchesCancelled

有人可以向我解释一下吗? 这是我的UIView中的打印代码(如果问题出现在那里)。

-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
    for (UITouch *touch in touches) {
        CGPoint location = [touch locationInView:touch.view];
        NSLog(@"Began  %f %f",  location.x, location.y);
    }
}


-(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
{  
    for (UITouch *touch in touches) {
        CGPoint location = [touch locationInView:touch.view];
        NSLog(@"Moved  %f %f",  location.x, location.y);
    }
}


-(void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{
    for (UITouch *touch in touches) {
        CGPoint location = [touch locationInView:touch.view];
        NSLog(@"Ended  %f %f",  location.x, location.y);
    }
}

-(void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event
{
    NSLog(@"Phase: Touches cancelled");

    for (UITouch *touch in touches) {
        CGPoint location = [touch locationInView:touch.view];
        NSLog(@"Cancelled  %f %f",  location.x, location.y);

    }
}

序列的一个例子就是这个:

Began  38.000000 263.000000
Began  173.500000 238.500000
Moved  41.500000 263.000000
Phase: Touches cancelled   <<<< third touch
Cancelled  41.500000 263.000000
Cancelled  173.500000 238.500000

谢谢。

0 个答案:

没有答案