iOS gesture Learning Uigesturerecognizer & cocos2d gesture Recommendations

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.