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
events
apache-nifi
odata
material-components
minecraft
rangy
mahout-recommender
synthesis
pickle
spam
coreldraw
altium-designer
router
data-collection
plyr
window-managers
clipboard
basic-authentication
region
xenapp
toad
windowsiot
vcenter
opnet
lxml
sca
android-collapsingtoolbar
nest
markov-chains
des
subclassing
bluemixtools
djcelery
unification
mars-simulator
oauth2
resampling
pyttsx
morphline
flume-twitter
absolute
axis
.net-micro-framework
return-type
cordova-ios
comm
amazon-elastic-beanstalk
skip-lists
kendo-treeview
hmmlearn
http4s
mifos
google-identity-toolkit
nsrunloop
seccomp
deferred-rendering
powerpoint-2013
strpos
textblock
outlook.com
android-studio-import
espresso
kefir.js
webproject
nssortdescriptor
operands
hp-idol-ondemand
encryption-symmetric
igor
mobile-country-code
communicate
two.js
pageviews
jms-serializer
meteorite
strdup
xs
jquery-lazyload
icenium
story
wndproc
sfinae
coordinate
microblogging
space-partitioning
page-curl
kext
jmenu
fgetc
asdoc
self-tracking-entities
data-retrieval
version-control-migration
acceleration

Resources

Database Users
RDBMS discuss
Database Dev&Adm
javascript
java
csharp
php
android
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App