Ios 触摸如果我不移动手指,则不会呼叫

Ios 触摸如果我不移动手指,则不会呼叫,ios,ipad,swift,touches,Ios,Ipad,Swift,Touches,我有一段简单的代码,其中覆盖了touchesbeated、end、Cancelled(空块)和touchesMoved。 若我用鼠标点击(我正在桌面PC上测试)开始,它会被调用,但只有当我移动手指一段时间后才会调用touchesEnded。这使得我们无法识别手指的一次轻触或拖动,并以不同的方式处理它们。 我不明白这是一个模拟器问题还是我误解了整个过程。你也有同样的问题吗 对于我的应用程序,我有一个简单的解决方案,比如在touchsbegind中检查“first-move”变量,但这是一个纯粹的技

我有一段简单的代码,其中覆盖了touchesbeated、end、Cancelled(空块)和touchesMoved。 若我用鼠标点击(我正在桌面PC上测试)开始,它会被调用,但只有当我移动手指一段时间后才会调用touchesEnded。这使得我们无法识别手指的一次轻触或拖动,并以不同的方式处理它们。 我不明白这是一个模拟器问题还是我误解了整个过程。你也有同样的问题吗

对于我的应用程序,我有一个简单的解决方案,比如在touchsbegind中检查“first-move”变量,但这是一个纯粹的技术问题

先谢谢你

这就是我使用的全部,除了drawRect,它并不重要。 我想这在我的代码中不是问题

override func touchesBegan(touches: NSSet, withEvent event: UIEvent) {
    let touch = touches.allObjects[0] as UITouch 
    let touchPoint = touch.locationInView(self) 

    println("touchesBegan")

    if (Draw!){
        path.moveToPoint(touchPoint)
        path.addLineToPoint(touchPoint)

        self.setNeedsDisplay()
    }
}
override func touchesMoved(touches: NSSet, withEvent event: UIEvent) {
    let touch = touches.allObjects[0] as UITouch
    let touchPoint = touch.locationInView(self)

    println("touchesMoved")

    if (Draw!){
        path.addLineToPoint(touchPoint)
        self.setNeedsDisplay()
    }
}

override func touchesEnded(touches: NSSet, withEvent event: UIEvent) {
    let touch = touches.allObjects[0] as UITouch
    let touchPoint = touch.locationInView(self)

    println("touchesEnded")

    if (Draw!){
        path.addLineToPoint(touchPoint  
        path = UIBezierPath() // Create new path for next line        
        self.setNeedsDisplay()
    }

}

我很确定这是一个模拟器问题

请参阅下面的代码。在我这边,它就像一个符咒

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
    didMove = false;
}

- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
{
    didMove = true;
}

- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{
    if (didMove == true)
    {
        //finger was moved
        NSLog(@"finger was moved");
    }
    else
    {
        //it's a tap
        NSLog(@"finger not moved it's a tap");
    }

}

在我们讨论的过程中,我能让您注意到UIGestureRecognitors吗?尝试使用它们,因为它们让生活变得轻松愉快。

请与我们分享您在这方面使用的代码。谢谢,我已经知道UIGesturesReceigners,但我只是在练习!