gestures


How to Stop Single Tap From firing before Double Tap


I am trying to set a simple double tap recognition before moving to more complicated interactions. I have the single and double tap being recognised. However, my problem is that the double tap doesn't fire without the single tap.
I have seen the code which covers introducing a requirement to fail, but the sample code I do not understand how to modify to make work with my standard approach.
Here is my code - at the moment I am just trying to get the log to fire and it is. But on double tap I get the single tap message which I don't want. I have tried changing the TapGestureRecognizer event settings to no avail.
- (IBAction)didTapPhoto1:(UITapGestureRecognizer *)sender; {
NSLog(#"Did Tap Photo1 !");
}
- (IBAction)didDoubleTapPhoto1:(UITapGestureRecognizer *)sender; {
NSLog(#"DoubleTap");
}
Thank you
Use UIGestureRecognizer requireGestureRecognizerToFail: method.
[singleTapGestureRecognizer requireGestureRecognizerToFail:doubleTapGestureRecognizer].
There is a side effect of this method, if you only tap one time on the screen, it will react slower than that without calling the method.
Edit: It seems that you create the gesture recognizer in Storyboard or xib. You can also do it with code.
UITapGestureRecognizer *singleGR = [[UITapGestureRecognizer alloc] initWithTarget:self action:#selector(didTapPhoto1:)] ;
singleGR.numberOfTapsRequired = 1 ;
UITapGestureRecognizer *doubleGR = [[UITapGestureRecognizer alloc] initWithTarget:self action:#selector(didDoubleTapPhoto1:)] ;
doubleGR.numberOfTapsRequired = 2 ;
// you can change self.view to any view in the hierarchy.
[self.view addGestureRecognizer:singleGR] ;
[self.view addGestureRecognizer:doubleGR] ;
[singleGR requireGestureRecognizerToFail:doubleGR] ;

Related Links

Ionic mobile app - disabling gestures in an area on iPad2
Can't get pinch zoom and rotate gestures working on a container in Nativescript
How to Stop Single Tap From firing before Double Tap
Microsoft Kinect SDK Zoom/Scroll getsures
cocos3d billboard paning with gestures

Categories

HOME
android-espresso
apache-nifi
lambda
vagrant
facebook-messenger
swi-prolog
systemd
plpgsql
google-play-services
tcp
cypher
google-sheets-query
swift2
google-search-console
pyresttest
tup
azure-logic-apps
mutation-testing
twitter-oauth
alljoyn
graphdb
documentum
django-rq
android-5.1.1-lollipop
office-ui-fabric
varnish-vcl
multiple-tables
gitkraken
anova
tableview
websphere-portal
mod-wsgi
xdebug
windowsiot
rust-cargo
series
overwrite
sql-execution-plan
mongoengine
subclassing
netstat
nsuserdefaults
xvfb
eclipse-gmf
sbjson
stat
windows-store
plane
angular-datatables
opal-framework
word-cloud
spooler
httphandler
expandablelistview
morphline
git-tfs
absolute
roracle
lightning-workbench
android-sharing
test-data
.when
msg
system.web.optimization
visual-studio-monaco
conan
wicked-pdf
xcopy
onepage-checkout
django-validation
ioexception
flask-security
android-studio-import
com0com
flow-js
erlog
shoes
camus
mathematical-expressions
kognitio-wx2
hp-idol-ondemand
iodocs
window-resize
otl
webautomation
coding-efficiency
accessory
rails-api
jack
revmob
stty
quickgraph
postgres-xc
semicolon
2d-vector
office-app
server-name
qtextbrowser
jquery-1.4
git-log
chunking
getimagesize
rtti
icon-language

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App