0

我有一个UIViewController并添加了一个UILongPressGestureRecognizer,当被识别时,它会在顶部添加一个子视图,该子视图覆盖UIViewController并将印刷机的坐标传递给子视图,并在印刷机所在的位置添加图像。

我现在需要做的是移动用户拇指所在的子视图。我已经实现touchesMoved了,UIView但是直到您删除手势并按下并重新开始后才注册?

如何在UIView添加后立即开始 touchesBegan 而无需删除并重新开始?

谢谢-JM

4

1 回答 1

1

为什么不继续使用 UILongPressGesture?

    - (IBAction)longPressGestureStateChanged:(UILongPressGestureRecognizer *)sender {
        switch (sender.state) {
            case UIGestureRecognizerStatePossible:
            case UIGestureRecognizerStateBegan: {
            /* PUT YOUR IMAGE HERE */
            break;
        }
        case UIGestureRecognizerStateChanged: {
            /* MOVE YOUR IMAGE HERE */
            self.myImageView.center = [sender locationInView:self.view /* or any of your subviews */];
            break;
        }
        case UIGestureRecognizerStateCancelled:
        case UIGestureRecognizerStateFailed:
        case UIGestureRecognizerStateEnded: {
            /* REMOVE OR PROCESS END OF THIS TOUCH GESTURE */
            break;
    }
}
于 2013-08-16T15:53:46.477 回答