I have a UITapGestureRecognizer which basically performs an action to add a subview. When I tap I only want the subview to load once, however when I tap twice really fast, it performs the action twice. How can I prevent this? Basically after it's tapped once I want the tap gesture recognizer to be disabled temporarily for some seconds. Is there a way to do this?
2 Answers
0
votes
Disable your tap recognizer in the selector that the recognizer calls. Override didAddSubview
in the view to which you add subviews on tapping the recognizer, and re-enable it from there. The recognizer will remain inactive through the time while the new subview is being added. If you animate the addition, you should get a sufficient delay to avoid reacting to double-taps.