About the iOS gesture Uigesturerecognizer issue

Source: Internet
Author: User

 typedef ns_enum (Nsinteger, uigesturerecognizerstate) { Uigesturerecognizerstatepossible,  //  No gesture action has been identified (but may have triggered a touch event), default state   Uigesturerecognizerstatebegan,  //  The gesture has started to be recognized at this time but may change in this process gesture action is not yet complete  uigesturerecognizerstatechanged, //  gesture state changed  uigesturerecognizerstateended, //gesture recognition is complete (the finger is now released)  Uigesturerecogn    izerstatecancelled, //gesture was canceled to the default state   Uigesturerecognizerstatefailed,//gesture recognition failed to revert to default state  uigesturerecognizerstaterecognized = Uigesturerecogni zerstateended //gesture recognition completed with end }; 
Uigesturerecognizer method
Ns_class_available_ios (3_2)@interfaceUigesturerecognizer:nsobject
Create a Gesture object and add a trigger event-(Instancetype) Initwithtarget: (NullableID) Target action: (nullable SEL) action Ns_designated_initializer; Add an event to a gesture-(void) AddTarget: (ID) Target action: (SEL) Action;
Removes a listener event for a gesture-(void) Removetarget: (NullableID) Target action: (nullable SEL) action;@property (nonatomic,ReadOnly) Uigesturerecognizerstate State;//Get current gesture status@property (nullable,nonatomic,weak)ID<UIGestureRecognizerDelegate>Delegate;//Principal Agent@property (nonatomic, Getter=isenabled) BOOL enabled;//whether gesture recognition is available@property (Nullable, Nonatomic,ReadOnly) UIView *view;//Get gesture Touch View graph Read OnlyWhether to cancel the response of the touch control
The default is yes, in which case when the gesture recognizer recognizes touch, it sends touchescancelled to the touch control to suppress the control view's response to touch, when only the gesture recognizer responds to touch,
When set to No, the gesture recognizer does not send touchescancelled to the control after it recognizes the touch, which is when both the gesture recognizer and the control view respond to touch. Note: Gesture recognition and touch events exist at the same time, just because touchescancelled causes touch events to expire,@property (nonatomic) BOOL Cancelstouchesinview;
Whether to delay sending touch events to the touch control
The default is no, in which case when a touch occurs, the gesture recognizer snaps to the touch and then sends the touch to the control, each responding. If set to Yes, the gesture recognizer is in the process of recognition (note that the recognition process),
The touch is not sent to the touch control, that is, the control does not have any touch events. Touch events are sent to the touch control only after the recognition has failed, in which case the response of the control view is delayed by approximately 0.15ms.
@property (nonatomic) BOOL Delaystouchesbegan;
Whether touch-aware touch events are terminated immediately after a failure to recognize the gesture
@property (nonatomic) BOOL delaystouchesended;
Specifies that one gesture requires another gesture execution to fail to execute, while triggering multiple gestures using one of the gestures of the solution
Sometimes gestures are associated, such as single-machine and double-click, click and long Press, point down instantly may only recognize the click unrecognized other, the method can specify a gesture, even if they have satisfied the condition, will not be triggered immediately, will wait until the specified gesture is determined to fail before triggering
-(void) Requiregesturerecognizertofail: (Uigesturerecognizer *) Othergesturerecognizer;
Gets the point of the current touch on the specified view
-(Cgpoint) Locationinview: (nullable uiview*) view;
The touch point of a multi-fingered touch relative to the position of the specified view
-(Cgpoint) Locationoftouch: (Nsuinteger) Touchindex InView: (nullable uiview*) view;

Uigesturerecognizer is an abstract class that defines the basic behavior of all gestures and uses its subclasses to handle specific gestures

UITapGestureRecognizer (light touch, TAP) Uilongpressgesturerecognizer (Long Press) Uiswipegesturerecognizer (swipe gesture) Uirotationgesturerecognizer (rotation gesture) UIPanGestureRecognizer ( Drag gestures) Uipinchgesturerecognizer (pinch gesture, zoom)

About the contents of the Uigesturerecognizerdelegate agent

//The method called when the gesture recognition is started returns no then the end recognition no longer triggers gesture usefulness: Gesture recognition can be used at the position specified by the control-(BOOL) Gesturerecognizershouldbegin: (Uigesturerecognizer *) Gesturerecognizer;//whether multiple gesture triggering is supported returns YES can be triggered with multiple gestures method return no is mutually exclusive//whether multiple gesture recognizers are allowed to recognize a space after gesture recognition if blocking gesture recognition continues to propagate downward by default returns no, if a Yes responder chain upper object triggers gesture recognition, if the underlying object also adds gestures and succeeds recognition will continue to execute, Otherwise, the upper object will no longer propagate after recognition-(BOOL) Gesturerecognizer: (Uigesturerecognizer *) Gesturerecognizer Shouldrecognizesimultaneouslywithgesturerecognizer: (Uigesturerecognizer *) Othergesturerecognizer;//This method returns Yes when the first gesture and the second gesture are mutually exclusive, the first one fails-(BOOL) Gesturerecognizer: (Uigesturerecognizer *) Gesturerecognizer Shouldrequirefailureofgesturerecognizer: ( Uigesturerecognizer *) Othergesturerecognizer Ns_available_ios (7_0);
//This method returns Yes when the first gesture and the second gesture are mutually exclusive, the second one fails -(BOOL) Gesturerecognizer: (Uigesturerecognizer *) Gesturerecognizer Shouldberequiredtofailbygesturerecognizer: ( Uigesturerecognizer *) Othergesturerecognizer Ns_available_ios (7_0);//The method of the callback after the finger touches the screen returns no is not triggered by the gesture recognition method-(BOOL) Gesturerecognizer: (Uigesturerecognizer *) Gesturerecognizer Shouldreceivetouch: (Uitouch *) Touch;//Called before PressesBegan:withEvent:is called on the gesture recognizer for a new press. Return NO to prevent the gesture recognizer from seeing this press
Returns no does not accept press events-(BOOL) Gesturerecognizer: (Uigesturerecognizer *) Gesturerecognizer shouldreceivepress: (uipress *) Press;
UITapGestureRecognizerconflict resolution for UIButton and click events
-(BOOL) Gesturerecognizer: (Uigesturerecognizer *) Gesturerecognizer Shouldreceivetouch: (Uitouch *) touch{     ifclass]])    {        return  NO;    }           return YES;}

Gesture Uigesturerecognizer issues with iOS

Related Article

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.