1

すべてのタッチイベントの座標を出力するシンプルなアプリがあります。シミュレーターでは、うまく機能します。

私のデバイス (iPhone) では、最大 2 本の指でうまく機能します。3 本の指ですばやくタップすると、イベント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

ありがとうございました。

4

0 に答える 0