使用三个手指时触发 TouchsCancelled

发布于 2024-12-17 14:50:53 字数 1461 浏览 2 评论 0原文

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

在我的设备 (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

谢谢。

I have a simple app that prints the coordinates of all the touches event.
In the simulator it works great.

On my device (iPhone) it works great with up to two fingers. When I tap with three fingers in a fast sequence the event touchesCancelled is triggered.

Could someone please explain this to me?
This is the code for printing (in case the problem lays there) that sits in my 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);

    }
}

An example of sequence is this one:

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

Thank you.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文