iPad应用程序-触摸开始双击不正确

iPad应用程序-触摸开始双击不正确,ipad,touchesbegan,Ipad,Touchesbegan,我有一个UIViewController,它具有touchesBegind功能并输出位置 - (void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { NSLog(@"in"); NSArray *touchesArray = [touches allObjects]; for(int i=0; i<1; i++) { UITouch *touch = (UITou

我有一个UIViewController,它具有touchesBegind功能并输出位置

- (void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { 
    NSLog(@"in");

    NSArray *touchesArray = [touches allObjects];
    for(int i=0; i<1; i++)
    {
        UITouch *touch = (UITouch *)[touchesArray objectAtIndex:i];
        CGPoint point = [touch locationInView:touch.view];
        NSLog(@"point = %f %f",point.x,point.y);
    }
}
为什么第二次点击被注册为(39,22)…就像iPad的左上角一样。但是,我在中间敲击。

所以,我想用两种方法来解决这个问题:

1) somehow, not let the user double tap (however it seems even when I double tap fast, the touchesBegan function is called on two separate occassions)
2) figure out why that 2nd tap is being registered with the wrong coordinates.

它应该是CGPoint=[touch locationInView:self.view];。。。当您轻触两次时,不会出现“touch.view”

1)触摸开始:withEvent:将被调用两次。(这就是它的工作原理)2)我怀疑你的双水龙头的每个水龙头都落在两个不同的视图中,别问我怎么不知道。但最合理的解决方案是将您的位置索引到一个已知的视图,例如:
locationInView:self.view
而不是
touch.view
,它将是触摸通过命中测试的任何视图。是的,这是有效的。不知道我为什么要放touch.view,哈哈,谢谢!
1) somehow, not let the user double tap (however it seems even when I double tap fast, the touchesBegan function is called on two separate occassions)
2) figure out why that 2nd tap is being registered with the wrong coordinates.