How to recognize oneTap/doubleTap at moment?

前端 未结 7 786
独厮守ぢ
独厮守ぢ 2020-12-05 05:51

I Know filtering oneTap/doubleTap using a Apple API. code are follows.

UITapGestureRecognizer *doubleTapGestureRecognizer = [[UITapGestureRecognizer alloc]
          


        
7条回答
  •  暖寄归人
    2020-12-05 06:42

    Swift 3.1 version of eladleb's answer.

    override func touchesBegan(_ touches: Set, with event: UIEvent) {
            super.touchesBegan(touches, with: event)
    
            DispatchQueue.main.asyncAfter(deadline: .now() + 0.3) { [weak self] in
                if self?.state != .recognized {
                    self?.state = .failed
                }
            }
        }
    

提交回复
热议问题