iOS gesture Learning Uigesturerecognizer & cocos2d gesture Recommendations
Gesture Recognition Type:
Uilongpressgesturerecognizer//Long Press
Uipangesturerecognizer//Slow drag
Uipinchgesturerecognizer//Two point inward or outward toggle
Uirotationgesturerecognizer//rotation
Uiswipegesturerecognizer//Quick Slide
UITapGestureRecognizer//click
Gesture protocol:
@protocol uigesturerecognizerdelegate <NSObject> @optional//Called when a gesture recognizer attempts to Transition out of uigesturerecognizerstatepossible. Returning NO causes it to transition to uigesturerecognizerstatefailed-(BOOL) Gesturerecognizershouldbegin: ( Uigesturerecognizer *) gesturerecognizer;//called when the recognition of one of Gesturerecognizer or Othergesturerecogni Zer would is blocked by the other//return YES to allow both to recognize simultaneously. The default implementation returns no (by default No, gestures can be recognized simultaneously)////note:returning YE S is guaranteed to allow simultaneous recognition. Returning guaranteed to prevent simultaneous recognition, as the other gesture ' s delegate may return yes-(BOOL) Gesturerecognizer: (Uigesturerecognizer *) Gesturerecognizer Shouldrecognizesimultaneouslywithgesturerecognizer: ( Uigesturerecognizer *) othergesturerecognizer;//called before TouchesBegan:withEvent:is called on the gesture REcognizer for a new touch. Return NO to prevent the gesture recognizer from seeing this touch-(BOOL) Gesturerecognizer: (Uigesturerecognizer *) gesture Recognizer Shouldreceivetouch: (Uitouch *) touch; @end
Gesture Priority:
Create a relationship with another gesture recognizer that'll prevent this gesture's actions from being called until Othergesturerecognizer transitions to uigesturerecognizerstatefailed//if othergesturerecognizer transitions to uigesturerecognizerstaterecognized or Uigesturerecognizerstatebegan then this recognizer would instead transition to uigesturerecognizerstatefailed//Example usage:a single tap could require a double tap to fail-(void) Requiregesturerecogni Zertofail: (Uigesturerecognizer *) Othergesturerecognizer;
Various gestures Demo:uigesturerecognizer Learning notes
Cocos2d Gesture Library Recommended: Sfgesturerecognizers GitHub links
iOS gesture Learning Uigesturerecognizer & cocos2d gesture Recommendations