【问题标题】:is that possible to trigger another gestureRecognizer in one gestureRecognizer (in swift)?是否可以在一个手势识别器中触发另一个手势识别器(快速)?
【发布时间】:2020-07-15 13:08:07
【问题描述】:

如果我长时间单击图像,然后开始 func actionLongPress,如您所见,如果我长时间单击图像,那么我想沿着我的触摸移动该图像...但是此代码不起作用... 没有错误。即使我长时间单击图像,图像也不会跟随我的触摸.. 你解决这个问题了吗???

@objc func actionLongPress(Recog : UILongPressGestureRecognizer){
        if Recog.state == .began{
            AudioServicesPlaySystemSound(1519) 
            addPanGesture(view: addedImage)
            origin = addedImage.frame.origin
            
        } else if Recog.state == .ended{
            AudioServicesPlaySystemSound(1519) 
            
        }
    }

【问题讨论】:

    标签: ios swift xcode image gesture


    【解决方案1】:

    您缺少一个需要实现的状态...即状态更改

    @objc func actionLongPress(Recog : UILongPressGestureRecognizer){
            if Recog.state == .began{
                AudioServicesPlaySystemSound(1519) 
                addPanGesture(view: addedImage)
                origin = addedImage.frame.origin
                
            } else if Recog.state == .changed {
    
                // assign view frame here
    
               let location = Recog.location(in: self)
                 your_view?.center = targetPosition
    
             } else if Recog.state == .ended{
                AudioServicesPlaySystemSound(1519) 
                
            }
        }
    

    【讨论】:

      猜你喜欢
      • 2017-06-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-04-06
      • 1970-01-01
      • 2015-07-23
      • 1970-01-01
      相关资源
      最近更新 更多