画面を特定の回数タップまたはタッチしたときに、スクリーンショットのように画面を保存する必要があるアプリを作成しています。私は他のユーザーが提案した私の質問に関連するすべての解決策を試しましたが、何も役に立ちません...
私はすべての提案に感謝します。:) ありがとう
The following blog post does a good job of explaining the built-in option for recognizing multiple taps in a row (and explains the shortcomings): Detecting tap and double-tap with Gesture Recognizers.
If you need more customized logic than is provided by the built-in gesture recognizers, you will either be implementing your own custom subclass of UIGestureRecognizer
or you will be adding your logic into the UIResponder
(superclass of UIViewController
, UIView
, etc.) callbacks for tap input: touchesBegan:withEvent:
, touchesMoved:withEvent:
, and touchesEnded:withEvent:
.
I have more experience with the latter method (not UIGestureRecognizer
). The UITouch
events passed to the various UIResponder
callbacks each contain information about touch location and touch timing. You could use this information in combination with a NSTimer
to determine if the user taps twice (or more) within a certain amount of time. If the timer fires before the second (or n
th touch), then you can consider it a single touch event.
I don't know if that is the best way to do this, but it is certainly more granular control than the built-in UIGestureRecognizer
s provide you.