【问题标题】:UILongPressGesture to Touches Moved in subviewONLongPressGesture to Touches Moved in subview
【发布时间】:2013-08-16 13:48:08
【问题描述】:

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

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

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

谢谢 -JM

【问题讨论】:

    标签: objective-c uiview touchesbegan touchesmoved long-press


    【解决方案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;
        }
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-03-04
      • 1970-01-01
      • 2018-05-26
      • 2022-12-28
      • 1970-01-01
      • 2022-12-27
      相关资源
      最近更新 更多