Ios UILongPressGestureRecognitor未识别。结束状态

Ios UILongPressGestureRecognitor未识别。结束状态,ios,swift,avfoundation,uilongpressgesturerecogni,Ios,Swift,Avfoundation,Uilongpressgesturerecogni,正如标题所示,我的问题是我的UILongPressGestureRecognitor有时不运行sender.state=.end中的代码。.start始终运行并工作。我曾试图注意到这种模式,但并不常见,我也没有找到一个有效的模式或因果关系。我只需将我的UITapGestureRecognitor UILong按GestureRecognitor添加到我的按钮: let tapGesture = UITapGestureRecognizer(target: self, action: #selec

正如标题所示,我的问题是我的UILongPressGestureRecognitor有时不运行
sender.state=.end
中的代码。
.start
始终运行并工作。我曾试图注意到这种模式,但并不常见,我也没有找到一个有效的模式或因果关系。我只需将我的UITapGestureRecognitor UILong按GestureRecognitor添加到我的按钮:

let tapGesture = UITapGestureRecognizer(target: self, action: #selector(normalTap(_:)))
tapGesture.numberOfTapsRequired = 1
camButton.addGestureRecognizer(tapGesture)

let longGesture = UILongPressGestureRecognizer(target: self, action: #selector(longTap(_:)))
longGesture.minimumPressDuration = 0.10
camButton.addGestureRecognizer(longGesture)
下面是我的longTap函数:

    @objc func longTap(_ sender: UIGestureRecognizer) {
            if sender.state == .ended {
                if movieOutput.recordedDuration.seconds == lastRecordDuration || movieOutput.recordedDuration.seconds <= 0.35 {
                    capturePhoto()
                    } else {
                    stopRecording()
                }
           } else if sender.state == .began {
            startCapture()
        }
    }
@objc func longTap(\发送方:UIgestureRecognitizer){
如果sender.state==.end{

如果movieOutput.recordedDuration.seconds==lastRecordDuration | | movieOutput.recordedDuration.seconds在接受@rmaddy的帮助后,解决方案基本上是实现一个.cancelled状态操作。由于某种原因,uilongpresssigner的连续手势被取消。在我的代码中,我实现了一个'if sender.state=.cancelled.

取消的
状态如何?如果你不添加点击手势怎么办?这对长按有什么影响吗?不,我有96.5%的信心它不会改变长手势识别器。我故意将长手势的最小保持设置为0.10,以便它与正常的点击手势重叠更少。但是如果你想它识别的是TapSirter而不是LongSirter,只需知道.begind实际上运行的是never.end,这是在录制一段时间后发生的。您可以尝试一个简单的输出命令,如“print(“end”),而不是捕获.也许这可以把问题从complex@Guilermoramirezblonski但是
cancelled
状态(或任何其他状态)如何?@rmaddy我的代码中当前没有活动的状态,但是我没有查看这些发送方状态。我应该实现它们吗?这样,如果它取消,它应该与.ended具有相同的代码?